Advertisement
Guest User

lab9_var4_alice

a guest
May 25th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     setlocale(LC_ALL, "Rus");
  8.     freopen("input.txt", "r", stdin);
  9.     string str;
  10.     cin >> str;
  11.     cout << "Начальная строка:" << "\n";
  12.     cout << str << "\n";
  13.     for (int i = 0; i < str.size(); i++) {
  14.         if (isdigit(str[i])) {
  15.             int index = stoi(str.substr(i, 1)) - 1;
  16.             str[i] = str[index];
  17.         }
  18.     }
  19.     cout << "Итоговая строка:" << "\n";
  20.     cout << str << "\n";
  21.     freopen("CON", "r", stdin); //возврат ввода через консоль
  22.     system("PAUSE");
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement