fork download
  1. #include <iostream>
  2. #include <sstream>
  3. using namespace std;
  4.  
  5. string chuanhoa(string s) {
  6. stringstream ss(s);
  7. string tu, res = "";
  8. while (ss >> tu) {
  9. tu[0] = toupper(tu[0]);
  10. for (int i = 1; i < tu.size(); i++) tu[i] = tolower(tu[i]);
  11. res += tu + " ";
  12. }
  13. res.pop_back();
  14. return res;
  15. }
  16.  
  17. int main() {
  18. int n;
  19. cin >> n;
  20. cin.ignore();
  21. while (n--) {
  22. string s;
  23. getline(cin, s);
  24. cout << chuanhoa(s) << endl;
  25. }
  26. }
  27.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty