Advertisement
Spocoman

04. Digits, Letters and Other

Nov 20th, 2023 (edited)
751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     string str, digits, letters, other;
  7.     cin >> str;
  8.  
  9.     for (int i = 0; i < str.length(); i++) {
  10.         if (isdigit(str[i])) {
  11.             digits += str[i];
  12.         }
  13.         else if (isalpha(str[i])) {
  14.             letters += str[i];
  15.         }
  16.         else {
  17.             other += str[i];
  18.         }
  19.     }
  20.  
  21.     cout << digits << endl
  22.         << letters << endl
  23.         << other << endl;
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement