Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main ()
- {
- char str[256];
- cin.getline(str, 256);
- char c;
- cout<<"Enter a number: ";
- cin>>c;
- int toChange = c - '0';
- if (str[strlen(str)-1]==c)
- {
- for (int i=0;i<toChange;i++)
- {
- str[i] = '&';
- }
- }
- for (int i=0;i<strlen(str);i++)
- {
- cout<<str[i];
- }
- cout<<endl;
- }
Add Comment
Please, Sign In to add comment