您的位置:首页 > 其它

HDU 2026 首字母变大写

2015-09-18 00:51 351 查看
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
char s[105];
while(gets(s))
{
int len = strlen(s);
printf("%c", s[0]-32);  //小写字母的ASCII比对应的大写字母大32
for(int i = 1; i < len; i++)
{
if(s[i-1] == ' ') printf("%c", s[i]-32);
else printf("%c", s[i]);
}
printf("\n");
}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: