2026——首字母變大寫

Problem Description
輸入一個英文句子,將每個單詞的第一個字母改成大寫字母。
 

Input
輸入數據包含多個測試實例,每個測試實例是一個長度不超過100的英文句子,佔一行。
 

Output
請輸出按照要求改寫後的英文句子。
 

Sample Input
i like acm i want to get an accepted
 

Sample Output
I Like Acm I Want To Get An Accepted
 

#include <stdio.h>
#include <string.h>
main()
{
     int x,i;
     char a[100];
     while(gets(a)!=NULL)                                             //gets失敗返回NULL 
     {
          x=strlen(a);
          a[0]-=32;
          for(i=1;i<x;i++)
              if(a[i]==' ')
                  a[i+1]-=32;
          puts(a);
     }
}

“an accepted”   ??!!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章