HDU 2026 首字母变大写

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 using namespace std;
 5 int main()
 6 {
 7     char s[105];
 8     while(gets(s))
 9     {
10         int len = strlen(s);
11         printf("%c", s[0]-32);  //小写字母的ASCII比对应的大写字母大32
12         for(int i = 1; i < len; i++)
13         {
14             if(s[i-1] == ' ') printf("%c", s[i]-32); 
15             else printf("%c", s[i]);
16         }
17         printf("\n");
18     }
19     return 0;
20 }
View Code

 

posted on 2015-09-18 00:51  改写历史,倾尽天下  阅读(102)  评论(0编辑  收藏  举报

导航