#include #include using namespace std; list s[15]; char x, c1, c2; int was, db; void read(int i) { scanf("%c", &x); while (x != '\n') { s[i].push_back(x); scanf("%c", &x); } } int main() { db = 0; read(db); while (s[db].front() != '0'){ db++; read(db); } for (int i = 0; i < db; i++) { was = 0; c2 = s[i].back(); s[i].pop_back(); s[i].pop_back(); c1 = s[i].back(); s[i].pop_back(); s[i].pop_back(); for (list::iterator it = s[i].begin(); it != s[i].end(); it++){ if (*it == c1) *it = c2; if (*it == '0'&& was) cout << *it; else if (*it != '0') { cout << *it; was = 1; } } cout << endl; } return 0; }