Advertisement
sheredega

task 12

Nov 4th, 2022
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cctype>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     string str;
  10.     char a;
  11.     cout << "Enter string: ";
  12.     getline(cin, str);
  13.     cout << "Enter letter: ";
  14.     cin >> a;
  15.  
  16.     for (int i = 0; i < str.length(); i++) {
  17.         if (str[i] == toupper(a) || str[i] == tolower(a)) {
  18.             str[i] = '@';
  19.         }
  20.     }
  21.     cout << "New string: ";
  22.     cout << str;
  23.  
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement