#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> s; int trans[10] = {-1}; memset(trans, -1, 10 * sizeof(int)); cin >> n; int idx, tmp; for (int i = 0; i < n; ++i) { scanf("%d%d", &idx, &tmp); trans[idx] = tmp; for (int j = 0; j < 10; ++j) { if (trans[j] == idx) { trans[j] = tmp; } } } for (auto &ch :s) { if (trans[ch - '0'] != -1) { ch = trans[ch - '0'] + '0'; } putchar(ch); } puts(""); return 0; }测了好久,始终0case,有大神帮忙看一下问题出在哪吗?
全部评论
(8) 回帖