kej

5.Дан текст, состоящий из слов, разделённых пробелами. Если

kej
Mar 2nd, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. int main ()
  5. {
  6.    
  7.     char str[256];
  8.     cin.getline(str, 256);
  9.     char c;
  10.     cout<<"Enter a number: ";
  11.     cin>>c;
  12.     int toChange = c - '0';
  13.    if (str[strlen(str)-1]==c)
  14.    {
  15.        for (int i=0;i<toChange;i++)
  16.        {
  17.            str[i] = '&';
  18.        }
  19.    }
  20.     for (int i=0;i<strlen(str);i++)
  21.     {
  22.         cout<<str[i];
  23.     }
  24.     cout<<endl;
  25.  
  26. }
Add Comment
Please, Sign In to add comment