在主函数中输入一个字符,定子函数,对字符串进行‘去数字”屏作,然后将所有小写字每转为大写,具他字符不变,最后输出结果
”去数字“ 是指丢弃所有数字吗?要写子函数实现?
//在主函数中输入一个字符,定子函数,对字符串进行‘去数字”屏作,然后将所有小写字每转为大写,具他字符不变,最后输出结果
#include <iostream>
using namespace std;
void fun(char *s)
{
int i=0,j=0;
while(s[i] != 0)
{
if(s[i] >='0' && s[i] <='9')
{
i++;
continue;
}
if(s[i] >= 'a' && s[i] <= 'z')
s[j++] = s[i] - 32;
else
s[j++] = s[i];
i++;
}
s[j] = 0;
}
int main()
{
char s[1000];
gets(s);
fun(s);
puts(s);
return 0;
}