Advertisement
Spocoman

06. Title Case

Oct 29th, 2023 (edited)
842
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string str;
  8.     getline(cin, str);
  9.     str[0] = toupper(str[0]);
  10.  
  11.     for (int i = 1; i < str.length(); i++) {
  12.         if (!isalpha(str[i - 1]) && islower(str[i])) {
  13.             str[i] = toupper(str[i]);
  14.         }
  15.     }
  16.  
  17.     cout << str << endl;
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement