fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5. ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  6. string s; getline(cin,s);
  7. while (s[0] == ' ') s.erase(0,1);
  8. while (s[s.size() - 1] == ' ') s.erase(s.size() - 1,1);
  9. s[0] = toupper(s[0]);
  10. string v;
  11. bool check = 0;
  12. for (char c : s){
  13. if (isspace(c)){
  14. if (!check){
  15. v += ' ';
  16. check = 1;
  17. }
  18. }
  19. else{
  20. v += c;
  21. check = 0;
  22. }
  23. }
  24. cout << v;
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty