#define _CRT_SECURE_NO_DEPRECATE #include #include using namespace std; string s; char c1, c2; int main(){ int i, ok; //freopen("test.in", "r", stdin); //freopen("test.out", "w", stdout); cin >> s >> c1 >> c2; while (s[0] != '0' || c1 != '0' || c2 != '0'){ for ( i = 0; i < s.size(); i++){ if (s[i] == c1) s[i] = c2; } ok = 1; for (i = 0; i < s.size(); i++){ if (ok){ if (s[i] != '0'){ if (s[i] == c1) cout << c2; else cout << s[i]; ok = 0; } } else{ if (s[i] == c1) cout << c2; else cout << s[i]; } } cout << '\n'; cin >> s >> c1 >> c2; } return 0; }