//编写程序输入一个字符串,删除字符串中的所有数字字符后输出此字符串
#include
#include
using namespace std;
void movestr(char *str,int i,int n)
{
for (int j = i; j < n-1; j++)
{
str[j] = str[j+ 1];
}
str[n - 1] = '\0';
}
void main()
{
char str[200] = {};
cout << "请输入字符串:" << endl;
cin >> str;
for (int i = 0,count=0; i < 200&&count<200; i++,count++)
{
if (isdigit(str[i]))
{
movestr(str, i, 200);
i--;
}
}
cout << str << endl;
system("pause");
}
你这程序很混乱阿
int length(i); 这是什么写法...
for (i=0;i++;)
这又是什么意思? 判断条件i++等于0,也就是这句语句等于没执行...
循环体没有大括号
后面更看不懂了...
#include
#include
int main()
{
using namespace std;
string str;
cin>>str;
for(string::size_type index=0;index!=str.size();++inde)
if(str[index]<'1' || str[index]>'9')
cout << str[index] << flush;
return 0;
}