首字母变大写

来源:互联网 发布:淘宝60s视频制作软件 编辑:程序博客网 时间:2024/04/29 21:38

首字母变大写

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 107   Accepted Submission(s) : 56

Font: Times New Roman | Verdana | Georgia

Font Size:

Problem Description

输入一个英文句子,将每个单词的第一个字母改成大写字母。

Input

输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行。

Output

请输出按照要求改写后的英文句子。

Sample Input

i like acmi want to get an accepted

Sample Output

I Like AcmI Want To Get An Accepted

C语言程序代码

/*这题比较简单,不做解释。
要点一:用gets()输入,以为有空格。
要点二:大小写转换ASCLL码相差32。
*/
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
 int i,j,n,m,l;
 char a[101];
 while(gets(a))
 {
  l=strlen(a);
  for(i=0;i<l;i++)
  {
   if(i==0||a[i-1]==' ')
   {
    a[i]-=32;
    printf("%c",a[i]);
   }
   else
       printf("%c",a[i]);
  }
  printf("\n");
 }
 return 0;
}

0 0
原创粉丝点击