Time Limit: 2000/1000 MS
(Java/Others) Memory Limit: 65536/32768 K
(Java/Others)
Total Submission(s): 28018 Accepted
Submission(s): 15543
解题报告:
此题要求不高,简化了许多。先将字符串的第0个字母变成大写,然后从第1个字母开始遍历字符串。当第i-1个字母是空格,i个字母是字母,将第i个字母变大写。
1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char buf[100]; 6 int i, len; 7 while(gets(buf)) 8 { 9 len = strlen(buf); 10 buf[0] -= 32; 11 for(i = 1; i <= len; i++) 12 { 13 if(buf[i-1] == ‘ ‘ && buf[i] != ‘ ‘) 14 buf[i] -= 32; 15 } 16 puts(buf); 17 } 18 return 0; 19 }
原文:http://www.cnblogs.com/la0bei/p/3652932.html