您的位置:首页 > 其它

删除字符串中的数字

2014-03-22 18:10 246 查看
#include <iostream>
using namespace std;

void RemoveNumber(char * str)
{
char *read = str;
char *write = str;

while (*read != '\0')
{
if (*read < '0' || *read > '9')
{
*write = *read;
write++;
}
read++;
}

*write = '\0';
}

int main()
{
char str[] = "a88b";
RemoveNumber(str);
cout<<str<<endl;
return 0;
}


a 8  8  b

a b  8  b

a b \0  b

畅游笔试题,复杂度O(n),STL remove算法。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: