首字母变大写

#include<iostream>
#include<string.h>
using namespace std;
int main ()
{
char s[105];
while(gets(s))
{
int m=strlen(s);
for(int i=0;i<m;i++)
{
if(i==0)
printf("%c",s[i]-32);
else if(s[i-1]==' ')
printf("%c",s[i]-32);
else
printf("%c",s[i]);
}
cout<<endl;
}
return 0;
}

英文句子的输入,可以用gets()

再就是判断首字母位置

猜你喜欢

转载自www.cnblogs.com/huanya/p/9320046.html