題目連結: https://zerojudge.tw/ShowProblem?problemid=a782
# 解題思路
每次讀入的第一個字母轉大寫輸出,並紀錄下那個字的第一個位置,之後,只要輸出最後一次更新的位置就好
# 程式碼
| #include <iostream> | |
| #include <cstring> | |
| using namespace std; | |
| int main(){ | |
| char s[1000]; | |
| while(cin.getline(s,1000)){ | |
| if(strcmp(s,"END")==0) | |
| break; | |
| int l=0; | |
| cout<<(char) toupper(s[l]); | |
| for(int i=1;i<strlen(s);i++){ | |
| if(s[i]==' '){ | |
| l=i+1; | |
| cout<<(char) toupper(s[l]); | |
|             } | |
|         } | |
| cout<<" "; | |
| for(int i=l;i<strlen(s);i++) | |
| cout<<s[i]; | |
| cout<<endl; | |
|     } | |
| } | 
