hdu 2026 首字母变大写

来源:互联网 发布:送父亲的礼物 知乎 编辑:程序博客网 时间:2024/05/16 08:58
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2026

题目大意:将一个英文句子,每个单词第一个首字母变大写。

 1 #include <stdio.h> 2 int main (void) 3 { 4     int i; 5     char ch[100]; 6     while(gets(ch)) 7     { 8         for (i=0; ch[i]!='\0'; i++) 9         {10             if(ch[0]>='a'&&ch[0]<='z')11                 ch[0]-=32;12             if (ch[i-1]==' ')13                 ch[i]-=32;14         }15         printf ("%s\n",ch);16     }17     return 0;18 }

 

0 0
原创粉丝点击