hdu_problem_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
*
*
*Author
*lcy
*
*
*Source
*C語言程序設計練習(四)
*
*
*Recommend
*lcy
*
*/
#include<iostream>
#include<string>
using namespace std;
int main() {
 string s;
 char x;
 while (getline(cin, s)) {
  s.at(0) -= 32;
  for (int i = 1; i < s.size(); i++) {
   if (s.at(i - 1) == ' ') s.at(i) -= 32;
  }
  cout << s << endl;
 }
 system("pause");
 return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章