output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <cstdio> #include <iostream> using namespace std; int main(){ while(1){ int n, m; char a[1000][3]; scanf(" %d", &n); if(n==0) break; for(int i=0; i<n; ++i){ scanf(" %c %c", &a[i][0], &a[i][1]); } scanf(" %d", &m); for(int i=0; i<m; ++i){ char c; scanf(" %c", &c); for(int j=0; j<n; ++j){ if(c==a[j][0]){ c=a[j][1]; break; } } printf("%c", c); } printf("\n"); } return 0; }
### Prompt Please provide a CPP coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <cstdio> #include <iostream> using namespace std; int main(){ while(1){ int n, m; char a[1000][3]; scanf(" %d", &n); if(n==0) break; for(int i=0; i<n; ++i){ scanf(" %c %c", &a[i][0], &a[i][1]); } scanf(" %d", &m); for(int i=0; i<m; ++i){ char c; scanf(" %c", &c); for(int j=0; j<n; ++j){ if(c==a[j][0]){ c=a[j][1]; break; } } printf("%c", c); } printf("\n"); } return 0; } ```
#include<iostream> #include<map> #include<vector> using namespace std; int main() { int n; while(cin>>n){ if(n==0) break; vector<char> ans; map<char,char> M; for(int i=0;i<n;i++){ char in,out; cin>>in>>out; M[in]=out; } int k; cin>>k; for(int i=0;i<k;i++){ char s; cin>>s; if(!M.count(s)){ ans.push_back(s); } else ans.push_back(M[s]); } for(int i=0;i<ans.size();i++) cout<<ans[i]; cout<<endl; } return 0; }
### Prompt Your task is to create a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<map> #include<vector> using namespace std; int main() { int n; while(cin>>n){ if(n==0) break; vector<char> ans; map<char,char> M; for(int i=0;i<n;i++){ char in,out; cin>>in>>out; M[in]=out; } int k; cin>>k; for(int i=0;i<k;i++){ char s; cin>>s; if(!M.count(s)){ ans.push_back(s); } else ans.push_back(M[s]); } for(int i=0;i<ans.size();i++) cout<<ans[i]; cout<<endl; } return 0; } ```
#include<stdio.h> int main(){ int n,m,i,j; char nn[1000000],nm[1000000],mm[1000000]; while(1){ scanf("%d",&n); if(!n)break; for(i=0;i<n;i++){ scanf(" %c %c",&nn[i],&nm[i]); } scanf("%d",&m); for(i=0;i<m;i++){ scanf(" %c",&mm[i]); for(j=0;j<n;j++)if(mm[i]==nn[j]){ mm[i]=nm[j]; break; } } puts(mm); } }
### Prompt Generate a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<stdio.h> int main(){ int n,m,i,j; char nn[1000000],nm[1000000],mm[1000000]; while(1){ scanf("%d",&n); if(!n)break; for(i=0;i<n;i++){ scanf(" %c %c",&nn[i],&nm[i]); } scanf("%d",&m); for(i=0;i<m;i++){ scanf(" %c",&mm[i]); for(j=0;j<n;j++)if(mm[i]==nn[j]){ mm[i]=nm[j]; break; } } puts(mm); } } ```
#include <iostream> #include <vector> #include <map> using namespace std; int main(void){ while (1) { int n; cin >> n; if (!n) break; map<char, char> trans; for (int i = 0; i < n; i++) { char c, c2; cin >> c >> c2; trans[c] = c2; } int m; cin >> m; for (int i = 0; i < m; i++) { char b; cin >> b; if (trans[b]) b = trans[b]; cout << b; } cout << endl; } }
### Prompt Your task is to create a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <vector> #include <map> using namespace std; int main(void){ while (1) { int n; cin >> n; if (!n) break; map<char, char> trans; for (int i = 0; i < n; i++) { char c, c2; cin >> c >> c2; trans[c] = c2; } int m; cin >> m; for (int i = 0; i < m; i++) { char b; cin >> b; if (trans[b]) b = trans[b]; cout << b; } cout << endl; } } ```
#include <iostream> using namespace std; int main(){ int n; while(cin >> n && n){ int m = 0, henkan[10000] = {}; char in, iin; for(int i = 0; i < n; i++){ cin >> in >> iin; int ctoi = in, ctoii = iin; henkan[ctoi] = ctoii; } cin >> m; for(int i = 0; i < m; i++){ cin >> in; int ctoi = in; if(henkan[ctoi]) ctoi = henkan[ctoi]; cout << (char)ctoi; } cout << endl; } }
### Prompt Please provide a cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main(){ int n; while(cin >> n && n){ int m = 0, henkan[10000] = {}; char in, iin; for(int i = 0; i < n; i++){ cin >> in >> iin; int ctoi = in, ctoii = iin; henkan[ctoi] = ctoii; } cin >> m; for(int i = 0; i < m; i++){ cin >> in; int ctoi = in; if(henkan[ctoi]) ctoi = henkan[ctoi]; cout << (char)ctoi; } cout << endl; } } ```
#include<iostream> using namespace std; char v[256];int n,m; int main(){ while(true){ cin>>n;for(int i=32;i<127;i++){v[i]=i;} if(n==0)break; for(int i=0;i<n;i++){char p,q;cin>>p>>q;v[p]=q;} cin>>m; for(int i=0;i<m;i++){ char f;cin>>f;cout<<v[f]; } cout<<endl; } return 0; }
### Prompt Your task is to create a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> using namespace std; char v[256];int n,m; int main(){ while(true){ cin>>n;for(int i=32;i<127;i++){v[i]=i;} if(n==0)break; for(int i=0;i<n;i++){char p,q;cin>>p>>q;v[p]=q;} cin>>m; for(int i=0;i<m;i++){ char f;cin>>f;cout<<v[f]; } cout<<endl; } return 0; } ```
#include <iostream> using namespace std; int main(){ int n,m,i,j; char **a,*b; while(cin>>n){ if(n==0){break;} a=new char*[n]; for(i=0;i<n;i++){ a[i]=new char[2]; } for(i=0;i<n;i++){ cin>>a[i][0]>>a[i][1]; } cin>>m; b=new char[m+1]; for(i=0;i<m;i++){ cin>>b[i]; for(j=0;j<n;j++){ if(b[i]==a[j][0]){ b[i]=a[j][1]; break; } } } b[m]='\0'; cout<<b<<endl; } return 0; }
### Prompt Construct a Cpp code solution to the problem outlined: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main(){ int n,m,i,j; char **a,*b; while(cin>>n){ if(n==0){break;} a=new char*[n]; for(i=0;i<n;i++){ a[i]=new char[2]; } for(i=0;i<n;i++){ cin>>a[i][0]>>a[i][1]; } cin>>m; b=new char[m+1]; for(i=0;i<m;i++){ cin>>b[i]; for(j=0;j<n;j++){ if(b[i]==a[j][0]){ b[i]=a[j][1]; break; } } } b[m]='\0'; cout<<b<<endl; } return 0; } ```
#import<iostream> #define z std::cin>> int main(){int n;for(char a,b;z n,n;puts("")){int d[256]={};for(;n--;d[a]=b-a)z a>>b;for(z n;n--;putchar(a+d[a]))z a;}}
### Prompt Please formulate a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #import<iostream> #define z std::cin>> int main(){int n;for(char a,b;z n,n;puts("")){int d[256]={};for(;n--;d[a]=b-a)z a>>b;for(z n;n--;putchar(a+d[a]))z a;}} ```
#include <iostream> using namespace std; char d[100000000],h[1000],h2[1000]; int main(){ int hN,dN; while(1){ cin>>hN; if(hN==0) break; for(int i=0;i<hN;i++){ cin>>h[i]>>h2[i]; } cin>>dN; for(int i=0;i<dN;i++){ cin>>d[i]; } for(int i=0;i<dN;i++){ for(int j=0;j<hN;j++){ if(d[i]==h[j]){ d[i]=h2[j]; break; } } cout<<d[i]; } cout<<endl; } return 0; }
### Prompt Generate a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; char d[100000000],h[1000],h2[1000]; int main(){ int hN,dN; while(1){ cin>>hN; if(hN==0) break; for(int i=0;i<hN;i++){ cin>>h[i]>>h2[i]; } cin>>dN; for(int i=0;i<dN;i++){ cin>>d[i]; } for(int i=0;i<dN;i++){ for(int j=0;j<hN;j++){ if(d[i]==h[j]){ d[i]=h2[j]; break; } } cout<<d[i]; } cout<<endl; } return 0; } ```
#include<iostream> using namespace std; int main(){ int n; while(cin>>n){ if(n==0) break; char c[n][2],s; for(int i=0;i<n;i++) cin >> c[i][0] >> c[i][1]; int m; cin >> m; for(int i=0;i<m;i++){ cin >> s; bool ok = true; for(int j=0;j<n;j++){ if(s==c[j][0]){ cout << c[j][1]; ok = false; break; } } if(ok) cout << s; } cout << endl; } return 0; }
### Prompt Please provide a cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> using namespace std; int main(){ int n; while(cin>>n){ if(n==0) break; char c[n][2],s; for(int i=0;i<n;i++) cin >> c[i][0] >> c[i][1]; int m; cin >> m; for(int i=0;i<m;i++){ cin >> s; bool ok = true; for(int j=0;j<n;j++){ if(s==c[j][0]){ cout << c[j][1]; ok = false; break; } } if(ok) cout << s; } cout << endl; } return 0; } ```
#include <iostream> using namespace std; int main(){ int n, m; char aft[130]; bool exi[130]; char a, b; while(true){ cin >> n; if(n == 0) break; for(int i = 0; i < 130; i++) exi[i] = false; for(int i = 0; i < n; i++){ cin >> a >> b; aft[(int)a] = b; exi[(int)a] = true; } cin >> m; for(int i = 0; i < m; i++){ cin >> a; if(exi[(int)a]) cout << aft[(int)a]; else cout << a; } cout << endl; } return 0; }
### Prompt Generate a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main(){ int n, m; char aft[130]; bool exi[130]; char a, b; while(true){ cin >> n; if(n == 0) break; for(int i = 0; i < 130; i++) exi[i] = false; for(int i = 0; i < n; i++){ cin >> a >> b; aft[(int)a] = b; exi[(int)a] = true; } cin >> m; for(int i = 0; i < m; i++){ cin >> a; if(exi[(int)a]) cout << aft[(int)a]; else cout << a; } cout << endl; } return 0; } ```
#include <iostream> using namespace std; int main() { int n, m; while (cin >> n){ if (n == 0){ break; } char bucket[256]; for (int i = 0; i < 256; i++){ bucket[i] = i; } for (int i = 0; i < n; i++){ char c, d; cin >> c >> d; bucket[c] = d; } cin >> m; for (int i = 0; i < m; i++){ char c; cin >> c; cout << bucket[c]; } cout << endl; } return 0; }
### Prompt Please formulate a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main() { int n, m; while (cin >> n){ if (n == 0){ break; } char bucket[256]; for (int i = 0; i < 256; i++){ bucket[i] = i; } for (int i = 0; i < n; i++){ char c, d; cin >> c >> d; bucket[c] = d; } cin >> m; for (int i = 0; i < m; i++){ char c; cin >> c; cout << bucket[c]; } cout << endl; } return 0; } ```
#include <iostream> using namespace std; char conv[128]; int main() { int n; while(cin >> n && n) { for(int i = 0; i < 128; ++i) conv[i] = i; for(int i = 0; i < n; ++i) { char a, b; cin >> a >> b; conv[a] = b; } int m; cin >> m; while(m--) { char c; cin >> c; cout << conv[c]; } cout << endl; } }
### Prompt Please create a solution in cpp to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; char conv[128]; int main() { int n; while(cin >> n && n) { for(int i = 0; i < 128; ++i) conv[i] = i; for(int i = 0; i < n; ++i) { char a, b; cin >> a >> b; conv[a] = b; } int m; cin >> m; while(m--) { char c; cin >> c; cout << conv[c]; } cout << endl; } } ```
#include<stdio.h> #include<iostream> using namespace std; int main(){ long long int N; while(1){ char G[1001]; for(int i=0;i<1000;i++) { G[i]=-1; } cin>>N;if(N==0)break; for(int i=0;i<N;i++){ char x,y; cin>>x>>y; G[x]=y; } int NN; cin>>NN; for(int i=0;i<NN;i++){ char h; cin>>h; if(G[h]==-1)cout<<h; else if(G[h]!=-1)cout<<G[h]; } cout<<endl; } return 0; }
### Prompt In cpp, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<stdio.h> #include<iostream> using namespace std; int main(){ long long int N; while(1){ char G[1001]; for(int i=0;i<1000;i++) { G[i]=-1; } cin>>N;if(N==0)break; for(int i=0;i<N;i++){ char x,y; cin>>x>>y; G[x]=y; } int NN; cin>>NN; for(int i=0;i<NN;i++){ char h; cin>>h; if(G[h]==-1)cout<<h; else if(G[h]!=-1)cout<<G[h]; } cout<<endl; } return 0; } ```
#include <iostream> #include <string> #include <map> using namespace std; int main() { int n, m; cin >> n; while (n > 0) { map<string, string> tr; for (int i = 0; i < n; i++) { string a, b; cin >> a >> b; tr[a] = b; } cin >> m; string s; for (int i = 0; i < m; i++) { string t; cin >> t; if (tr.find(t) != tr.end()) s += tr[t]; else s += t; } cout << s << endl; cin >> n; } return 0; }
### Prompt Generate a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <string> #include <map> using namespace std; int main() { int n, m; cin >> n; while (n > 0) { map<string, string> tr; for (int i = 0; i < n; i++) { string a, b; cin >> a >> b; tr[a] = b; } cin >> m; string s; for (int i = 0; i < m; i++) { string t; cin >> t; if (tr.find(t) != tr.end()) s += tr[t]; else s += t; } cout << s << endl; cin >> n; } return 0; } ```
#include <iostream> #include <vector> using namespace std; struct tr{ char f; char t; }; int main(){ vector<tr> trs; tr t; int n,m,l,f; while(cin>>n,n){ while(n--){ cin >> t.f >> t.t; trs.push_back(t); } cin>>m; while(m--){ f=0; cin >> t.f; for(l=0;l<trs.size();l++){ if(t.f==trs[l].f){ cout<<trs[l].t; f=1; break; } } if(!f)cout << t.f; } cout << endl; trs.clear(); } return 0; }
### Prompt Generate a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <vector> using namespace std; struct tr{ char f; char t; }; int main(){ vector<tr> trs; tr t; int n,m,l,f; while(cin>>n,n){ while(n--){ cin >> t.f >> t.t; trs.push_back(t); } cin>>m; while(m--){ f=0; cin >> t.f; for(l=0;l<trs.size();l++){ if(t.f==trs[l].f){ cout<<trs[l].t; f=1; break; } } if(!f)cout << t.f; } cout << endl; trs.clear(); } return 0; } ```
#include<iostream> using namespace std; struct str { char h; char w; }; str v[100000]; char t,b[100000]; int main() { long long int j,i,n,m; while(1) { cin>>n; if(n==0) break; for(i=0;i<n;i++) { cin>>v[i].h>>v[i].w; } cin>>m; for(i=0;i<m;i++) { cin>>t; for(j=0;j<n;j++) { if(t==v[j].h) { b[i]=v[j].w; break; } else b[i]=t; } } for(i=0;i<m;i++) { cout<<b[i]; } cout<<endl; } return 0; }
### Prompt Your challenge is to write a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> using namespace std; struct str { char h; char w; }; str v[100000]; char t,b[100000]; int main() { long long int j,i,n,m; while(1) { cin>>n; if(n==0) break; for(i=0;i<n;i++) { cin>>v[i].h>>v[i].w; } cin>>m; for(i=0;i<m;i++) { cin>>t; for(j=0;j<n;j++) { if(t==v[j].h) { b[i]=v[j].w; break; } else b[i]=t; } } for(i=0;i<m;i++) { cout<<b[i]; } cout<<endl; } return 0; } ```
#include <iostream> #include <map> using namespace std; int main(){ int n; char x,y; for(;cin>>n,n;cout<<endl){ map<char,char>m; for(;n;n--){ cin>>x>>y; m[x]=y; } for(cin>>n;n;n--){ cin>>x; cout<<(m[x]?m[x]:x); } } }
### Prompt Please formulate a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <map> using namespace std; int main(){ int n; char x,y; for(;cin>>n,n;cout<<endl){ map<char,char>m; for(;n;n--){ cin>>x>>y; m[x]=y; } for(cin>>n;n;n--){ cin>>x; cout<<(m[x]?m[x]:x); } } } ```
#include<iostream> using namespace std; int main() { int i, j, n, m; char be, af, tmp; while (1) { cin >> n; if (n == 0)break; char cvrt[128] = {}; for (i = 0; i < n; i++) { cin >> be >> af; cvrt[be] = af; } cin >> m; for (i = 0; i < m; i++) { cin >> tmp; if (cvrt[tmp] == 0) { cout << tmp; } else { cout << cvrt[tmp]; } } cout << endl; } return 0; }
### Prompt Develop a solution in cpp to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> using namespace std; int main() { int i, j, n, m; char be, af, tmp; while (1) { cin >> n; if (n == 0)break; char cvrt[128] = {}; for (i = 0; i < n; i++) { cin >> be >> af; cvrt[be] = af; } cin >> m; for (i = 0; i < m; i++) { cin >> tmp; if (cvrt[tmp] == 0) { cout << tmp; } else { cout << cvrt[tmp]; } } cout << endl; } return 0; } ```
#include<iostream> #include<string> using namespace std; int main(){ while(1){ int m,n; char cha[100000],con[100000],a[100000]; cin>>m; if(m==0)break; for(int i=0;i<m;i++){ cin>>cha[i]>>con[i]; } cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; for(int j=0;j<m;j++){ if(a[i]==cha[j]){ a[i]=con[j]; break; } } } for(int i=0;i<n;i++){ cout<<a[i]; } cout<<"\n"; } return 0; }
### Prompt Develop a solution in CPP to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<string> using namespace std; int main(){ while(1){ int m,n; char cha[100000],con[100000],a[100000]; cin>>m; if(m==0)break; for(int i=0;i<m;i++){ cin>>cha[i]>>con[i]; } cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; for(int j=0;j<m;j++){ if(a[i]==cha[j]){ a[i]=con[j]; break; } } } for(int i=0;i<n;i++){ cout<<a[i]; } cout<<"\n"; } return 0; } ```
#include<bits/stdc++.h> using namespace std; int main(void){ int n; int m; char data; bool flg=false; while(1){ cin>>n; char a[n+1],b[n+1]; if(n==0){ break; } for(int i=0;i<n;i++){ cin>>a[i]>>b[i]; } cin>>m; for(int i=0;i<m;i++){ cin>>data; flg=false; for(int j=0;j<n;j++){ if(data==a[j]&&!flg){ data=b[j]; flg=true; } } cout<<data; } cout<<endl; } return 0; }
### Prompt Create a solution in Cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<bits/stdc++.h> using namespace std; int main(void){ int n; int m; char data; bool flg=false; while(1){ cin>>n; char a[n+1],b[n+1]; if(n==0){ break; } for(int i=0;i<n;i++){ cin>>a[i]>>b[i]; } cin>>m; for(int i=0;i<m;i++){ cin>>data; flg=false; for(int j=0;j<n;j++){ if(data==a[j]&&!flg){ data=b[j]; flg=true; } } cout<<data; } cout<<endl; } return 0; } ```
#include<bits/stdc++.h> using namespace std; using Int = long long; //INSERT ABOVE HERE signed main(){ int n; while(cin>>n,n){ map<char,char> m; for(int i=0;i<n;i++){ char c,d; cin>>c>>d; m[c]=d; } string ans; int q; cin>>q; while(q--){ char x; cin>>x; if(m.count(x)) ans+=m[x]; else ans+=x; } cout<<ans<<endl; } return 0; }
### Prompt Your challenge is to write a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<bits/stdc++.h> using namespace std; using Int = long long; //INSERT ABOVE HERE signed main(){ int n; while(cin>>n,n){ map<char,char> m; for(int i=0;i<n;i++){ char c,d; cin>>c>>d; m[c]=d; } string ans; int q; cin>>q; while(q--){ char x; cin>>x; if(m.count(x)) ans+=m[x]; else ans+=x; } cout<<ans<<endl; } return 0; } ```
#include<string> #include<cstdio> #include<map> int main(){ using namespace std; int a,b; char c,d,s[9]; map<char,char> code; while(scanf("%d",&a),a){ while(a--){ scanf(" %c %c",&c,&d); code[c]=d; } scanf("%d",&a); while(a--){ scanf(" %c",&c); if(code.count(c)==1){ putchar(code[c]); } else{ putchar(c); } } printf("\n"); code.clear(); } return 0; }
### Prompt Your task is to create a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<string> #include<cstdio> #include<map> int main(){ using namespace std; int a,b; char c,d,s[9]; map<char,char> code; while(scanf("%d",&a),a){ while(a--){ scanf(" %c %c",&c,&d); code[c]=d; } scanf("%d",&a); while(a--){ scanf(" %c",&c); if(code.count(c)==1){ putchar(code[c]); } else{ putchar(c); } } printf("\n"); code.clear(); } return 0; } ```
#include <iostream> #include <map> using namespace std; int main(void){ int n; while(cin >> n && n){ char x,y; map<char,char> m; for(int i=0;i<n;i++){ cin >> x >> y; m[x] = y; } cin >> n; for(int i=0;i<n;i++){ cin >> x; if(m.find(x) == m.end()){ cout << x; }else{ cout << m[x]; } } cout << endl; } }
### Prompt Create a solution in cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <map> using namespace std; int main(void){ int n; while(cin >> n && n){ char x,y; map<char,char> m; for(int i=0;i<n;i++){ cin >> x >> y; m[x] = y; } cin >> n; for(int i=0;i<n;i++){ cin >> x; if(m.find(x) == m.end()){ cout << x; }else{ cout << m[x]; } } cout << endl; } } ```
#include<stdio.h> int main(void) { int n,m; int i,j; char a[100],b[100],c; scanf("%d",&n); while(n!=0){ for(i=0;i<n;i++){ scanf(" %c %c",&a[i],&b[i]); } scanf("%d",&m); for(i=0;i<m;i++){ scanf(" %c",&c); for(j=0;j<n;j++){ if(a[j]==c){ c=b[j]; break; } } printf("%c",c); } printf("\n"); scanf("%d",&n); } return 0; }
### Prompt Construct a cpp code solution to the problem outlined: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<stdio.h> int main(void) { int n,m; int i,j; char a[100],b[100],c; scanf("%d",&n); while(n!=0){ for(i=0;i<n;i++){ scanf(" %c %c",&a[i],&b[i]); } scanf("%d",&m); for(i=0;i<m;i++){ scanf(" %c",&c); for(j=0;j<n;j++){ if(a[j]==c){ c=b[j]; break; } } printf("%c",c); } printf("\n"); scanf("%d",&n); } return 0; } ```
#include <iostream> #define N 51 #define M 100001 using namespace std; int main() { while(true){ int n,m; char mae[N],ato[N]; cin >> n; if(n<=0) break; for(int i=0;i<n;i++){ cin >> mae[i] >> ato[i]; } cin >> m; for(int i=0;i<m;i++){ char ch; cin >> ch; for(int j=0;j<n;j++){ if(ch==mae[j]){ ch=ato[j]; break; } } cout << ch; } cout << endl; } return 0; }
### Prompt In Cpp, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #define N 51 #define M 100001 using namespace std; int main() { while(true){ int n,m; char mae[N],ato[N]; cin >> n; if(n<=0) break; for(int i=0;i<n;i++){ cin >> mae[i] >> ato[i]; } cin >> m; for(int i=0;i<m;i++){ char ch; cin >> ch; for(int j=0;j<n;j++){ if(ch==mae[j]){ ch=ato[j]; break; } } cout << ch; } cout << endl; } return 0; } ```
#include<iostream> #include<map> #include<stdio.h> using namespace std; int main(){ int in; while(1){ cin >> in; if(in == 0) break; map<char, char> M; char a, b; for(int i = 0; i < in; i++){ cin >> a >> b; M[a] = b; } cin >> in; for(int i = 0; i < in; i++){ cin >> a; if(M[a] != NULL) cout << M[a]; else cout << a; } cout << endl; } return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<map> #include<stdio.h> using namespace std; int main(){ int in; while(1){ cin >> in; if(in == 0) break; map<char, char> M; char a, b; for(int i = 0; i < in; i++){ cin >> a >> b; M[a] = b; } cin >> in; for(int i = 0; i < in; i++){ cin >> a; if(M[a] != NULL) cout << M[a]; else cout << a; } cout << endl; } return 0; } ```
#include <iostream> #include <string> using namespace std; int main(){ int n, m, z[200], xx, yy; string x, y, out; while (cin >> n) { if (n == 0) { break; } for (int i = 0; i < 200; i++) { z[i] = i; } out = ""; for (int i = 0; i < n; i++) { cin >> x >> y; xx = x[0]; yy = y[0]; z[xx] = yy; } cin >> m; for (int i = 0; i < m; i++) { cin >> x; n = x[0]; out += z[n]; } cout << out << endl; } return 0; }
### Prompt In Cpp, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <string> using namespace std; int main(){ int n, m, z[200], xx, yy; string x, y, out; while (cin >> n) { if (n == 0) { break; } for (int i = 0; i < 200; i++) { z[i] = i; } out = ""; for (int i = 0; i < n; i++) { cin >> x >> y; xx = x[0]; yy = y[0]; z[xx] = yy; } cin >> m; for (int i = 0; i < m; i++) { cin >> x; n = x[0]; out += z[n]; } cout << out << endl; } return 0; } ```
#include <iostream> #include <map> using namespace std; int main() { int n; while( cin >> n, n ) { map<char, char> mp; for( int i=0; i<n; i++ ) { char a, b; cin >> a >> b; mp[a] = b; } string res = ""; int m; cin >> m; for( int i=0; i<m; i++ ) { char a; cin >> a; if( mp.count(a) ) a = mp[a]; res += a; } cout << res << endl; } return 0; }
### Prompt Please create a solution in CPP to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <map> using namespace std; int main() { int n; while( cin >> n, n ) { map<char, char> mp; for( int i=0; i<n; i++ ) { char a, b; cin >> a >> b; mp[a] = b; } string res = ""; int m; cin >> m; for( int i=0; i<m; i++ ) { char a; cin >> a; if( mp.count(a) ) a = mp[a]; res += a; } cout << res << endl; } return 0; } ```
#include <stdio.h> #define num_element 150 int main(void) { int i,n,m; char array[num_element]; char a[2]; char b[2]; char input[2]; while(1) { for(i=0;i<num_element;i++) { array[i] = i; } scanf("%d",&n); if(n == 0)return 0; for(i=0;i<n;i++) { scanf("%s %s",a,b); array[a[0]] = b[0]; } scanf("%d",&m); for(i=0;i<m;i++) { scanf("%s",input); printf("%c",array[input[0]]); } printf("\n"); } return 0; }
### Prompt Develop a solution in Cpp to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <stdio.h> #define num_element 150 int main(void) { int i,n,m; char array[num_element]; char a[2]; char b[2]; char input[2]; while(1) { for(i=0;i<num_element;i++) { array[i] = i; } scanf("%d",&n); if(n == 0)return 0; for(i=0;i<n;i++) { scanf("%s %s",a,b); array[a[0]] = b[0]; } scanf("%d",&m); for(i=0;i<m;i++) { scanf("%s",input); printf("%c",array[input[0]]); } printf("\n"); } return 0; } ```
#include <iostream> using namespace std; int main() { int n, m; char cstr[100][2], str[1000000]; cin >> n; while (n != 0){ for (int i = 0; i < n; i++) cin >> cstr[i][0] >> cstr[i][1]; cin >> m; for (int i = 0; i < m; i++){ cin >> str[i]; for (int j = 0; j < n; j++){ if (str[i] == cstr[j][0]){ str[i] = cstr[j][1]; break; } } } for (int i = 0; i < m; i++) cout << str[i]; cout << endl; cin >> n; } }
### Prompt Create a solution in cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main() { int n, m; char cstr[100][2], str[1000000]; cin >> n; while (n != 0){ for (int i = 0; i < n; i++) cin >> cstr[i][0] >> cstr[i][1]; cin >> m; for (int i = 0; i < m; i++){ cin >> str[i]; for (int j = 0; j < n; j++){ if (str[i] == cstr[j][0]){ str[i] = cstr[j][1]; break; } } } for (int i = 0; i < m; i++) cout << str[i]; cout << endl; cin >> n; } } ```
#include <iostream> #include <map> using namespace std; map<char, char> conv; int main() { int n, m; while((cin >> n) && n) { conv.clear(); for(int i = 0; i < n; ++i) { char a, b; cin >> a >> b; conv[a] = b; } cin >> m; for(int i = 0; i < m; ++i) { char c; cin >> c; if(conv[c] == 0) cout << c; else cout << conv[c]; } cout << endl; } }
### Prompt Your task is to create a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <map> using namespace std; map<char, char> conv; int main() { int n, m; while((cin >> n) && n) { conv.clear(); for(int i = 0; i < n; ++i) { char a, b; cin >> a >> b; conv[a] = b; } cin >> m; for(int i = 0; i < m; ++i) { char c; cin >> c; if(conv[c] == 0) cout << c; else cout << conv[c]; } cout << endl; } } ```
#include <stdio.h> #include <iostream> using namespace std; int main() { int n; char k[100][2]; int m; char a; while (cin >> n) { if (n == 0) { break; } for (int i = 0; i < n; i++) { cin >> k[i][0] >> k[i][1]; } cin >> m; for (int i = 0; i < m; i++) { cin >> a; for (int i = 0; i < n; i++) { if (a == k[i][0]) { a = k[i][1]; break; } } cout << a; } cout << endl; } return 0; }
### Prompt Develop a solution in Cpp to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <stdio.h> #include <iostream> using namespace std; int main() { int n; char k[100][2]; int m; char a; while (cin >> n) { if (n == 0) { break; } for (int i = 0; i < n; i++) { cin >> k[i][0] >> k[i][1]; } cin >> m; for (int i = 0; i < m; i++) { cin >> a; for (int i = 0; i < n; i++) { if (a == k[i][0]) { a = k[i][1]; break; } } cout << a; } cout << endl; } return 0; } ```
#include<iostream> #include<map> using namespace std; int main(void) { map<char, char> chgMap; int num; char in1, in2; int i; while(true) { cin >> num; if(num == 0) { break; } chgMap.clear(); for(i = 0; i < num; i++) { cin >> in1 >> in2; chgMap[in1] = in2; } cin >> num; for(i = 0; i < num; i++) { cin >> in1; if(chgMap.find(in1) != chgMap.end()) { cout << chgMap[in1]; } else { cout << in1; } } cout << endl; } return 0; }
### Prompt Your task is to create a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<map> using namespace std; int main(void) { map<char, char> chgMap; int num; char in1, in2; int i; while(true) { cin >> num; if(num == 0) { break; } chgMap.clear(); for(i = 0; i < num; i++) { cin >> in1 >> in2; chgMap[in1] = in2; } cin >> num; for(i = 0; i < num; i++) { cin >> in1; if(chgMap.find(in1) != chgMap.end()) { cout << chgMap[in1]; } else { cout << in1; } } cout << endl; } return 0; } ```
#include <iostream> #include <cstdio> using namespace std; int main(){ long i,j,n,m; char rend[65536][2],cash; while(1){ cin >> n; if(!n) break; for(i=0;i<n;i++){scanf(" %c %c",&rend[i][0],&rend[i][1]);} cin >> m; for(j=0;j<m;j++){ cin >> cash; for(i=0;i<n;i++){ if(cash==rend[i][0]){cash=rend[i][1];break;} } cout << cash; } cout << endl; } return 0; }
### Prompt Please create a solution in cpp to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <cstdio> using namespace std; int main(){ long i,j,n,m; char rend[65536][2],cash; while(1){ cin >> n; if(!n) break; for(i=0;i<n;i++){scanf(" %c %c",&rend[i][0],&rend[i][1]);} cin >> m; for(j=0;j<m;j++){ cin >> cash; for(i=0;i<n;i++){ if(cash==rend[i][0]){cash=rend[i][1];break;} } cout << cash; } cout << endl; } return 0; } ```
#include <iostream> #include <map> int main(int argc, char** argv){ int n; while(std::cin >> n, n){ std::map<char, char> trans; for(; n > 0; --n){ char before, after; std::cin >> before >> after; trans[before] = after; } std::cin >> n; for(; n > 0; --n){ char c; std::cin >> c; if(trans.count(c) == 1) c = trans[c]; std::cout << c; } std::cout << std::endl; } }
### Prompt Create a solution in cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <map> int main(int argc, char** argv){ int n; while(std::cin >> n, n){ std::map<char, char> trans; for(; n > 0; --n){ char before, after; std::cin >> before >> after; trans[before] = after; } std::cin >> n; for(; n > 0; --n){ char c; std::cin >> c; if(trans.count(c) == 1) c = trans[c]; std::cout << c; } std::cout << std::endl; } } ```
#include <iostream> #include <map> using namespace std; int main( void ) { while (1) { map <char, char> T; int n; cin >> n; if ( n == 0) break; for ( int i = 0; i < n; ++i ) { char c; cin >> c; cin >> T[c]; } string answer; int m; cin >> m; for ( int i = 0; i < m; ++i ) { char c; cin >> c; if( T.find(c) != T.end() ) answer += T[c]; else answer += c; } cout << answer << endl; } return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <map> using namespace std; int main( void ) { while (1) { map <char, char> T; int n; cin >> n; if ( n == 0) break; for ( int i = 0; i < n; ++i ) { char c; cin >> c; cin >> T[c]; } string answer; int m; cin >> m; for ( int i = 0; i < m; ++i ) { char c; cin >> c; if( T.find(c) != T.end() ) answer += T[c]; else answer += c; } cout << answer << endl; } return 0; } ```
#include <iostream> using namespace std; int main() { int n, m; char table[256]; while (cin >> n, n) { for (int i = 0; i < 256; i++) table[i] = 0; for (int i = 0; i < n; i++) { char a, b; cin >> a >> b; table[a] = b; } cin >> m; for (int i = 0; i < m; i++) { char a; cin >> a; if (table[a]) cout << table[a]; else cout << a; } cout << endl; } return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main() { int n, m; char table[256]; while (cin >> n, n) { for (int i = 0; i < 256; i++) table[i] = 0; for (int i = 0; i < n; i++) { char a, b; cin >> a >> b; table[a] = b; } cin >> m; for (int i = 0; i < m; i++) { char a; cin >> a; if (table[a]) cout << table[a]; else cout << a; } cout << endl; } return 0; } ```
#include <cstdio> #include <cstring> char tb[128]; int main() { int n,m; while(scanf("%d",&n),n) { memset(tb,0,sizeof(tb)); for(int i=0;i<n;i++) { getchar(); char ch1=getchar(),ch2=(getchar(),getchar()); tb[ch1]=ch2; } scanf("%d",&m); for(int i=0;i<m;i++) { getchar(); char ch=getchar(); if(tb[ch]==0) putchar(ch); else putchar(tb[ch]); } putchar('\n'); } }
### Prompt Develop a solution in cpp to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <cstdio> #include <cstring> char tb[128]; int main() { int n,m; while(scanf("%d",&n),n) { memset(tb,0,sizeof(tb)); for(int i=0;i<n;i++) { getchar(); char ch1=getchar(),ch2=(getchar(),getchar()); tb[ch1]=ch2; } scanf("%d",&m); for(int i=0;i<m;i++) { getchar(); char ch=getchar(); if(tb[ch]==0) putchar(ch); else putchar(tb[ch]); } putchar('\n'); } } ```
#include <iostream> int main(void){ char hen[128]; int n; while(true){ for(int i=0; i<128; i++) hen[i] = i; std::cin >> n; if(!n) break; for(int i=0; i<n; i++){ char from, to; std::cin >> from >> to; hen[from] = to; } std::cin >> n; for(int i=0; i<n; i++){ char c; std::cin >> c; std::cout << hen[c]; } std::cout << '\n'; } return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> int main(void){ char hen[128]; int n; while(true){ for(int i=0; i<128; i++) hen[i] = i; std::cin >> n; if(!n) break; for(int i=0; i<n; i++){ char from, to; std::cin >> from >> to; hen[from] = to; } std::cin >> n; for(int i=0; i<n; i++){ char c; std::cin >> c; std::cout << hen[c]; } std::cout << '\n'; } return 0; } ```
#include<iostream> #include<map> #include<stdio.h> using namespace std; int main(){ int in; while(1){ cin >> in; if(in == 0) break; map<char, char> M; char a, b; for(int i = 0; i < in; i++){ cin >> a >> b; M[a] = b; } cin >> in; for(int i = 0; i < in; i++){ cin >> a; if(M[a] != '\0') cout << M[a]; else cout << a; } cout << endl; } return 0; }
### Prompt Construct a cpp code solution to the problem outlined: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<map> #include<stdio.h> using namespace std; int main(){ int in; while(1){ cin >> in; if(in == 0) break; map<char, char> M; char a, b; for(int i = 0; i < in; i++){ cin >> a >> b; M[a] = b; } cin >> in; for(int i = 0; i < in; i++){ cin >> a; if(M[a] != '\0') cout << M[a]; else cout << a; } cout << endl; } return 0; } ```
#include <iostream> using namespace std; int main(){ int n,i,tail; char s; char dic[256]; while(cin>>n,n){ for(i=0;i<256;i++) dic[i]=i; while(n--){ cin>>s; cin>>dic[(int)s]; } cin>>n; while(n--){ cin>>s; cout<<dic[(int)s]; } cout<<endl; } }
### Prompt Please provide a CPP coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main(){ int n,i,tail; char s; char dic[256]; while(cin>>n,n){ for(i=0;i<256;i++) dic[i]=i; while(n--){ cin>>s; cin>>dic[(int)s]; } cin>>n; while(n--){ cin>>s; cout<<dic[(int)s]; } cout<<endl; } } ```
#include <bits/stdc++.h> using namespace std; int main(){ int N,M; char graph[128]; while(scanf("%d",&N),N){ for(int i = 0;i < 128;i++)graph[i] = i; char a,b; for(int i = 0;i < N;i++){ scanf(" %c %c",&a,&b); graph[a] = b; } cin >> M; for(int i = 0;i < M;i++){ scanf(" %c",&a); cout << graph[a]; } cout << endl; } return 0; }
### Prompt Generate a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main(){ int N,M; char graph[128]; while(scanf("%d",&N),N){ for(int i = 0;i < 128;i++)graph[i] = i; char a,b; for(int i = 0;i < N;i++){ scanf(" %c %c",&a,&b); graph[a] = b; } cin >> M; for(int i = 0;i < M;i++){ scanf(" %c",&a); cout << graph[a]; } cout << endl; } return 0; } ```
#include <stdio.h> int main(){ int n,i,j,m,f; char a[100],b[100],x; while(1){ scanf("%d ",&n); if(n==0)break; for(i=0;i<n;i++){ scanf("%c %c ",&a[i],&b[i]); } scanf("%d ",&m); for(i=0;i<m;i++){ scanf("%c ",&x); f=0; for(j=0;j<n;j++){ if(x==a[j]){ printf("%c",b[j]); f=1; break; } } if(f==0){ printf("%c",x); } } printf("\n"); } return 0; }
### Prompt Develop a solution in CPP to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <stdio.h> int main(){ int n,i,j,m,f; char a[100],b[100],x; while(1){ scanf("%d ",&n); if(n==0)break; for(i=0;i<n;i++){ scanf("%c %c ",&a[i],&b[i]); } scanf("%d ",&m); for(i=0;i<m;i++){ scanf("%c ",&x); f=0; for(j=0;j<n;j++){ if(x==a[j]){ printf("%c",b[j]); f=1; break; } } if(f==0){ printf("%c",x); } } printf("\n"); } return 0; } ```
#include<iostream> #include<map> using namespace std; int main(){ int n, m; char a, b; map<char, char> ma; while(cin >> n, n){ ma.clear(); for(int i=0; i < n; i++){ cin >> a >> b; ma[a] = b; } cin >> m; for(int i=0; i < m; i++){ cin >> a; if(ma[a] != '\0') cout << ma[a]; else cout << a; } cout << endl; } }
### Prompt Construct a Cpp code solution to the problem outlined: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<map> using namespace std; int main(){ int n, m; char a, b; map<char, char> ma; while(cin >> n, n){ ma.clear(); for(int i=0; i < n; i++){ cin >> a >> b; ma[a] = b; } cin >> m; for(int i=0; i < m; i++){ cin >> a; if(ma[a] != '\0') cout << ma[a]; else cout << a; } cout << endl; } } ```
#include<iostream> #include<algorithm> #include<vector> #include<map> #include<string> using namespace std; int main(){ int n; while(cin>>n,n){ string str=""; string bef="",aft=""; for(int i=0;i<n;i++){ char b,a; cin>>b>>a; bef+=b; aft+=a; } int n2; cin>>n2; for(int i=0;i<n2;i++){ char a; cin>>a; for(int j=0;j<n;j++){ if(a==bef[j]){ a=aft[j]; break; } } str+=a; } cout<<str<<endl; } return 0; }
### Prompt In Cpp, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<algorithm> #include<vector> #include<map> #include<string> using namespace std; int main(){ int n; while(cin>>n,n){ string str=""; string bef="",aft=""; for(int i=0;i<n;i++){ char b,a; cin>>b>>a; bef+=b; aft+=a; } int n2; cin>>n2; for(int i=0;i<n2;i++){ char a; cin>>a; for(int j=0;j<n;j++){ if(a==bef[j]){ a=aft[j]; break; } } str+=a; } cout<<str<<endl; } return 0; } ```
#include <bits/stdc++.h> #define r(i,n) for(int i=0;i<n;i++) using namespace std; int main(){ int n,m; string s; while(cin>>n,n){ char a[n][3],d; r(i,n){cin>>a[i][0]>>a[i][1];} cin>>m; char s[m]; r(i,m)cin>>s[i]; r(i,m){r(j,n)if(s[i]==a[j][0]){s[i]=a[j][1];break;}} r(i,m)cout<<s[i]; cout<<endl; } }
### Prompt Create a solution in cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <bits/stdc++.h> #define r(i,n) for(int i=0;i<n;i++) using namespace std; int main(){ int n,m; string s; while(cin>>n,n){ char a[n][3],d; r(i,n){cin>>a[i][0]>>a[i][1];} cin>>m; char s[m]; r(i,m)cin>>s[i]; r(i,m){r(j,n)if(s[i]==a[j][0]){s[i]=a[j][1];break;}} r(i,m)cout<<s[i]; cout<<endl; } } ```
#include <iostream> #include <map> using namespace std; int main(){ char a,b; int n, m; while(true){ map<char,char> mp; cin >> n; if( !n ) break; while( n-- ){ cin >> a >> b; mp[a] = b; } cin >> m; while( m-- ){ cin >> a; if( mp.find(a) == mp.end() ) cout << a; else cout << mp[a]; } cout << endl; } }
### Prompt Please provide a cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <map> using namespace std; int main(){ char a,b; int n, m; while(true){ map<char,char> mp; cin >> n; if( !n ) break; while( n-- ){ cin >> a >> b; mp[a] = b; } cin >> m; while( m-- ){ cin >> a; if( mp.find(a) == mp.end() ) cout << a; else cout << mp[a]; } cout << endl; } } ```
#include <stdio.h> int main(){ int n,m; int i,j; scanf("%d",&n); while(n!=0){ char before[n],after[n]; for(i=0;i<n;i++){ scanf(" %c %c",&before[i],&after[i]); } scanf("%d",&m); char data[m]; for(i=0;i<m;i++){ scanf(" %c",&data[i]); for(j=0;j<n;j++){ if(data[i]==before[j]){ data[i]=after[j]; break; } } } for(i=0;i<m;i++){ printf("%c",data[i]); } printf("\n"); scanf("%d",&n); } return 0; }
### Prompt Develop a solution in cpp to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <stdio.h> int main(){ int n,m; int i,j; scanf("%d",&n); while(n!=0){ char before[n],after[n]; for(i=0;i<n;i++){ scanf(" %c %c",&before[i],&after[i]); } scanf("%d",&m); char data[m]; for(i=0;i<m;i++){ scanf(" %c",&data[i]); for(j=0;j<n;j++){ if(data[i]==before[j]){ data[i]=after[j]; break; } } } for(i=0;i<m;i++){ printf("%c",data[i]); } printf("\n"); scanf("%d",&n); } return 0; } ```
#include <iostream> using namespace std; int main(){ int n; while(1){ cin >> n; if(n==0) break; int data[130]; for(int i=0;i<130;i++){ data[i]=i; } for(int i=0;i<n;i++){ char a, b; cin >> a >> b; data[(int)a]=(int)b; } int m; cin >> m; for(int i=0;i<m;i++){ char in; cin >> in; cout << (char)data[(int)in]; } cout << endl; } return 0; }
### Prompt Generate a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main(){ int n; while(1){ cin >> n; if(n==0) break; int data[130]; for(int i=0;i<130;i++){ data[i]=i; } for(int i=0;i<n;i++){ char a, b; cin >> a >> b; data[(int)a]=(int)b; } int m; cin >> m; for(int i=0;i<m;i++){ char in; cin >> in; cout << (char)data[(int)in]; } cout << endl; } return 0; } ```
#include<iostream> #include<map> #include<string> using namespace std; int main(){ int n; while(cin>>n && n){ map<string,string> change; for(int i=0;i<n;i++){ string s1,s2; cin>>s1>>s2; change[s1]=s2; } int m; cin>>m; string ans; for(int i=0;i<m;i++){ string s; cin>>s; if(change.find(s)!=change.end())s=change[s]; ans+=s; } cout<<ans<<endl; } }
### Prompt Create a solution in Cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<map> #include<string> using namespace std; int main(){ int n; while(cin>>n && n){ map<string,string> change; for(int i=0;i<n;i++){ string s1,s2; cin>>s1>>s2; change[s1]=s2; } int m; cin>>m; string ans; for(int i=0;i<m;i++){ string s; cin>>s; if(change.find(s)!=change.end())s=change[s]; ans+=s; } cout<<ans<<endl; } } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); while(n){ map<char,char> trans; char c1,c2; for(int i=0;i<n;i++){ scanf(" %c %c",&c1,&c2); trans[c1]=c2; } scanf("%d",&n); for(int i=0;i<n;i++){ scanf(" %c",&c1); if(trans.find(c1)!=trans.end()){ printf("%c",trans[c1]); }else{ printf("%c",c1); } } printf("\n"); scanf("%d",&n); } return 0; }
### Prompt Your task is to create a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); while(n){ map<char,char> trans; char c1,c2; for(int i=0;i<n;i++){ scanf(" %c %c",&c1,&c2); trans[c1]=c2; } scanf("%d",&n); for(int i=0;i<n;i++){ scanf(" %c",&c1); if(trans.find(c1)!=trans.end()){ printf("%c",trans[c1]); }else{ printf("%c",c1); } } printf("\n"); scanf("%d",&n); } return 0; } ```
#import<iostream> using namespace std; int main(){ int n, m; char a, b; while(cin>>n, n){ int d[256] = {}; for(int i=0;i<n;i++){ cin >> a >> b; d[a] = b-a; } for(cin>>n;n--;printf("%c", a+d[a])) cin>>a; puts(""); } }
### Prompt Create a solution in cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #import<iostream> using namespace std; int main(){ int n, m; char a, b; while(cin>>n, n){ int d[256] = {}; for(int i=0;i<n;i++){ cin >> a >> b; d[a] = b-a; } for(cin>>n;n--;printf("%c", a+d[a])) cin>>a; puts(""); } } ```
#include<iostream> using namespace std; int main() { for(int n;cin>>n,n;){ char map[128]; for(int i=0;i<128;i++) map[i]=0; for(int i=0;i<n;i++){ char a,b; cin>>a>>b; map[a]=b; } int l; cin>>l; for(int i=0;i<l;i++){ char c; cin>>c; cout<<(map[c]?map[c]:c); } cout<<endl; } return 0; }
### Prompt Create a solution in cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> using namespace std; int main() { for(int n;cin>>n,n;){ char map[128]; for(int i=0;i<128;i++) map[i]=0; for(int i=0;i<n;i++){ char a,b; cin>>a>>b; map[a]=b; } int l; cin>>l; for(int i=0;i<l;i++){ char c; cin>>c; cout<<(map[c]?map[c]:c); } cout<<endl; } return 0; } ```
#include <iostream> using namespace std; char dic[64][2]={""}; int main(){ int n,i,tail; char s; while(1){ tail=0; cin>>n; if(!n) return 0; while(n--){ cin>>dic[tail][0]; cin>>dic[tail++][1]; } cin>>n; while(n--){ for(cin>>s,i=0;i<tail;i++) if(s == dic[i][0]){ cout<<dic[i][1]; break;} if(i==tail) cout<<s; } cout<<endl; } }
### Prompt In CPP, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; char dic[64][2]={""}; int main(){ int n,i,tail; char s; while(1){ tail=0; cin>>n; if(!n) return 0; while(n--){ cin>>dic[tail][0]; cin>>dic[tail++][1]; } cin>>n; while(n--){ for(cin>>s,i=0;i<tail;i++) if(s == dic[i][0]){ cout<<dic[i][1]; break;} if(i==tail) cout<<s; } cout<<endl; } } ```
#include <cstdio> #include <cstring> char C[127]; int main() { int n,m; while(scanf("%d",&n),n) { getchar(); char ch1,ch2; memset(C,0,sizeof(C)); for(int i=0;i<n;i++) { ch1=getchar();getchar(); ch2=getchar();getchar(); C[ch1]=ch2; } scanf("%d",&m); getchar(); for(int i=0;i<m;i++) { char ch=getchar();getchar(); if(C[ch])printf("%c",C[ch]); else printf("%c",ch); } putchar('\n'); } }
### Prompt Generate a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <cstdio> #include <cstring> char C[127]; int main() { int n,m; while(scanf("%d",&n),n) { getchar(); char ch1,ch2; memset(C,0,sizeof(C)); for(int i=0;i<n;i++) { ch1=getchar();getchar(); ch2=getchar();getchar(); C[ch1]=ch2; } scanf("%d",&m); getchar(); for(int i=0;i<m;i++) { char ch=getchar();getchar(); if(C[ch])printf("%c",C[ch]); else printf("%c",ch); } putchar('\n'); } } ```
#include<iostream> #include<map> using namespace std; int main() { while (1){ int n; cin >> n; if(n == 0) break; map <char,char> a2b; char a,b; for(int i = 0;i < n; i++){ cin >> a >> b; a2b[a]=b; } int m; cin >> m; for(int i = 0;i < m; i++){ cin >> a; if( a2b.count(a) == 0 ) cout << a; else cout << a2b[a]; } cout << endl; } return 0; }
### Prompt Your task is to create a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<map> using namespace std; int main() { while (1){ int n; cin >> n; if(n == 0) break; map <char,char> a2b; char a,b; for(int i = 0;i < n; i++){ cin >> a >> b; a2b[a]=b; } int m; cin >> m; for(int i = 0;i < m; i++){ cin >> a; if( a2b.count(a) == 0 ) cout << a; else cout << a2b[a]; } cout << endl; } return 0; } ```
#include<bits/stdc++.h> using namespace std; map<char,char> ma; int main(){ ios_base::sync_with_stdio(false); int n,m; char a,b; while(1){ cin >> n; if(n==0) break; for(int i=0;i<n;i++){ cin >> a >> b; ma[a]=b; } cin >> m; char temp; for(int i=0;i<m;i++){ cin >> temp; if(ma[temp]!=0){ cout << ma[temp]; }else{ cout << temp; } } cout << endl; ma.clear(); } return 0; }
### Prompt In Cpp, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<bits/stdc++.h> using namespace std; map<char,char> ma; int main(){ ios_base::sync_with_stdio(false); int n,m; char a,b; while(1){ cin >> n; if(n==0) break; for(int i=0;i<n;i++){ cin >> a >> b; ma[a]=b; } cin >> m; char temp; for(int i=0;i<m;i++){ cin >> temp; if(ma[temp]!=0){ cout << ma[temp]; }else{ cout << temp; } } cout << endl; ma.clear(); } return 0; } ```
#include<bits/stdc++.h> using namespace std; map<char,char> mem; int main(){ char c; int n,m; while(cin>>n,n){ mem.clear(); for(int i=0;i<n;i++){ char a,b; cin>>a>>b; mem[a]=b; } cin>>m; for(int i=0;i<m;i++){ cin>>c; if(mem.find(c)!=mem.end()){ cout<<mem[c]; } else{ cout<<c; } } cout<<endl; } }
### Prompt Generate a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<bits/stdc++.h> using namespace std; map<char,char> mem; int main(){ char c; int n,m; while(cin>>n,n){ mem.clear(); for(int i=0;i<n;i++){ char a,b; cin>>a>>b; mem[a]=b; } cin>>m; for(int i=0;i<m;i++){ cin>>c; if(mem.find(c)!=mem.end()){ cout<<mem[c]; } else{ cout<<c; } } cout<<endl; } } ```
//24 #include<iostream> using namespace std; int main(){ for(int n;cin>>n,n;){ char t[128]={}; while(n--){ char a,b; cin>>a>>b; t[a]=b; } int m; cin>>m; while(m--){ char c; cin>>c; cout<<((t[c])?t[c]:c); } cout<<endl; } return 0; }
### Prompt Your challenge is to write a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp //24 #include<iostream> using namespace std; int main(){ for(int n;cin>>n,n;){ char t[128]={}; while(n--){ char a,b; cin>>a>>b; t[a]=b; } int m; cin>>m; while(m--){ char c; cin>>c; cout<<((t[c])?t[c]:c); } cout<<endl; } return 0; } ```
#include<iostream> #include<cstdio> #include<map> using namespace std ; int main(){ int n; char a,b; for(;;){ map<char,char> a2b; cin>>n; if(n==0)break; for(int i=0;i<n;i++){ cin >> a >> b; a2b[a]=b; } cin>>n; for(int i=0;i<n;i++){ cin>>a; if(a2b.count(a)==0){ cout<<a; } else cout<<a2b[a]; } cout<<endl; } return 0; }
### Prompt Please provide a cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<cstdio> #include<map> using namespace std ; int main(){ int n; char a,b; for(;;){ map<char,char> a2b; cin>>n; if(n==0)break; for(int i=0;i<n;i++){ cin >> a >> b; a2b[a]=b; } cin>>n; for(int i=0;i<n;i++){ cin>>a; if(a2b.count(a)==0){ cout<<a; } else cout<<a2b[a]; } cout<<endl; } return 0; } ```
#include <iostream> #include <cstdio> using namespace std; #define rep(i,n) for(int i=0;i<n;++i) #define rep1(i,n) for(int i=1;i<=n;++i) #define ALL(c) (c).begin(),(c).end() char s[10000],t[10000]; int main(){ while(true){ int n; cin >> n; if(!n) break; rep(i,n) cin >> s[i] >> t[i]; int m; cin >> m; rep(i,m){ char c,ans; cin >> c; ans=c; rep(i,n) if(c==s[i]) ans=t[i]; cout << ans; } cout << endl; } return 0; }
### Prompt Your challenge is to write a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <cstdio> using namespace std; #define rep(i,n) for(int i=0;i<n;++i) #define rep1(i,n) for(int i=1;i<=n;++i) #define ALL(c) (c).begin(),(c).end() char s[10000],t[10000]; int main(){ while(true){ int n; cin >> n; if(!n) break; rep(i,n) cin >> s[i] >> t[i]; int m; cin >> m; rep(i,m){ char c,ans; cin >> c; ans=c; rep(i,n) if(c==s[i]) ans=t[i]; cout << ans; } cout << endl; } return 0; } ```
#include<iostream> #include<string> #include<map> using namespace std; int main() { int n, o; while (cin >> n, n) { map<char, char>m; for (int i = 0;i < n;i++) { char a, b; cin >> a >> b; m[a]=b; } cin >> o; string sa; for (int i = 0;i < o;i++) { char a; cin >> a; auto itr = m.find(a); if (itr != m.end()) { sa += itr->second; } else { sa += a; } } cout << sa << endl; } return 0; }
### Prompt Your challenge is to write a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<string> #include<map> using namespace std; int main() { int n, o; while (cin >> n, n) { map<char, char>m; for (int i = 0;i < n;i++) { char a, b; cin >> a >> b; m[a]=b; } cin >> o; string sa; for (int i = 0;i < o;i++) { char a; cin >> a; auto itr = m.find(a); if (itr != m.end()) { sa += itr->second; } else { sa += a; } } cout << sa << endl; } return 0; } ```
#include<iostream> using namespace std; int main(){ while(1){ int a, mozi; cin >> a ; if(a==0)break; char wrong[a], right[a]; for(int i=0; i < a; i++){ cin >> wrong[i] >> right[i]; } cin >> mozi; char mozire[mozi]; for(int j=0; j < mozi; j++){ cin >> mozire[j]; for(int f=0; f < a; f++){ if(mozire[j] == wrong[f]){ mozire[j] = right[f]; break;}} } for(int e = 0; e < mozi; e++) cout << mozire[e]; cout << endl; } return 0; }
### Prompt Develop a solution in Cpp to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> using namespace std; int main(){ while(1){ int a, mozi; cin >> a ; if(a==0)break; char wrong[a], right[a]; for(int i=0; i < a; i++){ cin >> wrong[i] >> right[i]; } cin >> mozi; char mozire[mozi]; for(int j=0; j < mozi; j++){ cin >> mozire[j]; for(int f=0; f < a; f++){ if(mozire[j] == wrong[f]){ mozire[j] = right[f]; break;}} } for(int e = 0; e < mozi; e++) cout << mozire[e]; cout << endl; } return 0; } ```
#include <iostream> using namespace std; int main() { for (;;) { int n; cin >> n; if (!n) return 0; char T[128]; for (int i = 0; i < 128; i++) T[i] = char(i); for (int i = 0; i < n; i++) { char f, t; cin >> f >> t; T[f] = t; } int m; cin >> m; for (int i = 0; i < m; i++) { char c; cin >> c; cout << T[c]; } cout << endl; } }
### Prompt Your task is to create a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main() { for (;;) { int n; cin >> n; if (!n) return 0; char T[128]; for (int i = 0; i < 128; i++) T[i] = char(i); for (int i = 0; i < n; i++) { char f, t; cin >> f >> t; T[f] = t; } int m; cin >> m; for (int i = 0; i < m; i++) { char c; cin >> c; cout << T[c]; } cout << endl; } } ```
#include <iostream> using namespace std; int main(){ int n,m; char c[128],f; string s; while(cin >> n && n){ s = ""; for(int i=0;i<128;i++)c[i]=i; for(int i=0;i<n;i++){ cin >> f; cin >> c[f]; } cin >> m; for(int i=0;i<m;i++){ cin >> f; s += c[f]; } cout << s << endl; } }
### Prompt Construct a Cpp code solution to the problem outlined: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main(){ int n,m; char c[128],f; string s; while(cin >> n && n){ s = ""; for(int i=0;i<128;i++)c[i]=i; for(int i=0;i<n;i++){ cin >> f; cin >> c[f]; } cin >> m; for(int i=0;i<m;i++){ cin >> f; s += c[f]; } cout << s << endl; } } ```
#include<iostream> #define max 255 using namespace std; int main(){ char c,ch,d,change[max]; int n,m; while(cin >>n && n!=0){ for(int i=0;i<max;i++)change[i]=i; for(int i=0;i<n;i++){ cin >>c>>ch; change[c]=ch; } cin >>m; for(int i=0;i<m;i++){ cin >>d; cout <<change[d]; } cout <<endl; } return 0;}
### Prompt Please provide a cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #define max 255 using namespace std; int main(){ char c,ch,d,change[max]; int n,m; while(cin >>n && n!=0){ for(int i=0;i<max;i++)change[i]=i; for(int i=0;i<n;i++){ cin >>c>>ch; change[c]=ch; } cin >>m; for(int i=0;i<m;i++){ cin >>d; cout <<change[d]; } cout <<endl; } return 0;} ```
/* JOI 2006  予選 問2 言語 : C++ 必須知識: */ #include <iostream> using namespace std; int main(void) { int N,M; while( cin >> N, N > 0){ char change[1000]={}; // 大雑把に配列確保 char a,b; for(int i = 0; i < N; i++){ cin >> a >> b; change[a] = b; } cin >> M; char c; for(int i = 0; i < M; i++){ cin >> c; if(change[c] > 0) cout << change[c]; else cout << c; } cout << endl; } return 0; }
### Prompt Your challenge is to write a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp /* JOI 2006  予選 問2 言語 : C++ 必須知識: */ #include <iostream> using namespace std; int main(void) { int N,M; while( cin >> N, N > 0){ char change[1000]={}; // 大雑把に配列確保 char a,b; for(int i = 0; i < N; i++){ cin >> a >> b; change[a] = b; } cin >> M; char c; for(int i = 0; i < M; i++){ cin >> c; if(change[c] > 0) cout << change[c]; else cout << c; } cout << endl; } return 0; } ```
#include <stdio.h> int main(){ int n,i,j,m,f; char a[256],b[256],x; while(1){ scanf("%d ",&n); if(n==0){ break; } for(i=0;i<n;i++){ scanf("%s %s ",&a[i],&b[i]); } scanf("%d ",&m); for(i=0;i<m;i++){ scanf("%s",&x); f=0; for(j=0;j<n;j++){ if(x==a[j]){ printf("%c",b[j]); f=1; break; } } if(f==0){ printf("%c",x); } } printf("\n"); } return 0; }
### Prompt Please create a solution in Cpp to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <stdio.h> int main(){ int n,i,j,m,f; char a[256],b[256],x; while(1){ scanf("%d ",&n); if(n==0){ break; } for(i=0;i<n;i++){ scanf("%s %s ",&a[i],&b[i]); } scanf("%d ",&m); for(i=0;i<m;i++){ scanf("%s",&x); f=0; for(j=0;j<n;j++){ if(x==a[j]){ printf("%c",b[j]); f=1; break; } } if(f==0){ printf("%c",x); } } printf("\n"); } return 0; } ```
#include <iostream> using namespace std; int main(){ int n = 0; while(cin >> n && n){ int m = 0, henkan[10000] = {}; char in, iin; for(int i = 0; i < n; i++){ cin >> in >> iin; int ctoi = in, ctoii = iin; henkan[ctoi] = ctoii; } cin >> m; for(int i = 0; i < m; i++){ cin >> in; int ctoi = in; if(henkan[ctoi]) ctoi = henkan[ctoi]; cout << (char)ctoi; } cout << endl; } }
### Prompt Please formulate a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main(){ int n = 0; while(cin >> n && n){ int m = 0, henkan[10000] = {}; char in, iin; for(int i = 0; i < n; i++){ cin >> in >> iin; int ctoi = in, ctoii = iin; henkan[ctoi] = ctoii; } cin >> m; for(int i = 0; i < m; i++){ cin >> in; int ctoi = in; if(henkan[ctoi]) ctoi = henkan[ctoi]; cout << (char)ctoi; } cout << endl; } } ```
#include<iostream> #include<string> using namespace std; int main(){ int n; int m; char data[5000][2]; string s; while(true){ cin>>n; if(n==0)break; string str; for(int i=0;i<n;i++){ cin>>data[i][0]>>data[i][1]; } cin>>m; for(int i=0;i<m;i++){ cin>>s; str=str+s; } for(int i=0;i<str.size();i++){ for(int j=0;j<n;j++){ if(data[j][0]==str[i]){ str[i]=data[j][1]; break; } } } cout<<str<<endl; } return 0; }
### Prompt In Cpp, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<string> using namespace std; int main(){ int n; int m; char data[5000][2]; string s; while(true){ cin>>n; if(n==0)break; string str; for(int i=0;i<n;i++){ cin>>data[i][0]>>data[i][1]; } cin>>m; for(int i=0;i<m;i++){ cin>>s; str=str+s; } for(int i=0;i<str.size();i++){ for(int j=0;j<n;j++){ if(data[j][0]==str[i]){ str[i]=data[j][1]; break; } } } cout<<str<<endl; } return 0; } ```
#include <iostream> using namespace std; int main(){ int n, m; char c[256]; char a,b; while( cin >> n && n ){ for( int i=0;i<256;i++ ) c[i] = '.'; while( n-- ){ cin >> a >> b; c[(int)a] = b; } cin >> m; while( m-- ){ cin >> a; if( c[(int)a]!='.' ){ cout << c[(int)a]; // c[(int)a] = '.'; }else{ cout << a; } } cout << endl; } return 0; }
### Prompt In Cpp, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main(){ int n, m; char c[256]; char a,b; while( cin >> n && n ){ for( int i=0;i<256;i++ ) c[i] = '.'; while( n-- ){ cin >> a >> b; c[(int)a] = b; } cin >> m; while( m-- ){ cin >> a; if( c[(int)a]!='.' ){ cout << c[(int)a]; // c[(int)a] = '.'; }else{ cout << a; } } cout << endl; } return 0; } ```
#include<iostream> using namespace std; int main() { while (true){ int n; cin >> n; if (!n) break; char order[128]; for (int i = 0; i < 128; i++) order[i] = i; for (int i = 0; i < n; i++){ char in1, in2; cin >> in1 >> in2; order[in1] = in2; } int m; cin >> m; for (int i = 0; i < m; i++){ char in; cin >> in; cout << order[in]; } cout << endl; } return 0; }
### Prompt Create a solution in Cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> using namespace std; int main() { while (true){ int n; cin >> n; if (!n) break; char order[128]; for (int i = 0; i < 128; i++) order[i] = i; for (int i = 0; i < n; i++){ char in1, in2; cin >> in1 >> in2; order[in1] = in2; } int m; cin >> m; for (int i = 0; i < m; i++){ char in; cin >> in; cout << order[in]; } cout << endl; } return 0; } ```
#include <iostream> #include <map> #include <string> using namespace std; int main ( void ) { int n; while ( cin >> n, n ) { map<char, char> t; for (int i = 0; i < n; ++i) { char a, b; cin >> a >> b; t[a] = b; } int m; cin >> m; string out = ""; for (int i = 0; i < m; ++i) { char c; cin >> c; if ( t.count(c) ) out += t[c]; else out += c; } cout << out << endl; } return 0; }
### Prompt Generate a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <map> #include <string> using namespace std; int main ( void ) { int n; while ( cin >> n, n ) { map<char, char> t; for (int i = 0; i < n; ++i) { char a, b; cin >> a >> b; t[a] = b; } int m; cin >> m; string out = ""; for (int i = 0; i < m; ++i) { char c; cin >> c; if ( t.count(c) ) out += t[c]; else out += c; } cout << out << endl; } return 0; } ```
#include <stdio.h> int main(){ int n,i,j,m,f; char a[100],b[100],x; while(1){ scanf("%d ",&n); if(n==0){ break; } for(i=0;i<n;i++){ scanf("%c %c ",&a[i],&b[i]); } scanf("%d ",&m); for(i=0;i<m;i++){ scanf("%c ",&x); f=0; for(j=0;j<n;j++){ if(x==a[j]){ printf("%c",b[j]); f=1; break; } } if(f==0){ printf("%c",x); } } printf("\n"); } return 0; }
### Prompt In Cpp, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <stdio.h> int main(){ int n,i,j,m,f; char a[100],b[100],x; while(1){ scanf("%d ",&n); if(n==0){ break; } for(i=0;i<n;i++){ scanf("%c %c ",&a[i],&b[i]); } scanf("%d ",&m); for(i=0;i<m;i++){ scanf("%c ",&x); f=0; for(j=0;j<n;j++){ if(x==a[j]){ printf("%c",b[j]); f=1; break; } } if(f==0){ printf("%c",x); } } printf("\n"); } return 0; } ```
#include<iostream> using namespace std ; int main() { int n ; while( cin >> n ,n ) { char C[ n + 1 ] ,c[ n + 1 ] ; for( int i = 0 ; i < n ; i++ ) { cin >> C[ i ] >> c[ i ] ; } int m ; char str ; cin >> m ; for( int i = 0 ; i < m ; i++ ) { cin >> str ; for( int j = 0 ; j < n ; j++ ) { if( str == C[ j ] ) { cout << c[ j ] ; goto next ; } } cout << str ; next : ; } cout << endl ; } return 0 ; }
### Prompt Your task is to create a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> using namespace std ; int main() { int n ; while( cin >> n ,n ) { char C[ n + 1 ] ,c[ n + 1 ] ; for( int i = 0 ; i < n ; i++ ) { cin >> C[ i ] >> c[ i ] ; } int m ; char str ; cin >> m ; for( int i = 0 ; i < m ; i++ ) { cin >> str ; for( int j = 0 ; j < n ; j++ ) { if( str == C[ j ] ) { cout << c[ j ] ; goto next ; } } cout << str ; next : ; } cout << endl ; } return 0 ; } ```
#include <iostream> using namespace std; int main(){ int n; char henkan[1000]; char ch,t_ch; while( cin >> n,n){ for(int i = 0 ; i < 1000 ; i++ )henkan[i] = '\0'; while(n--){ cin >> ch >> t_ch; henkan[ ch ] = t_ch; } cin >> n; while(n--){ cin >> ch; if(henkan[ ch ] != '\0'){ cout << henkan[ ch ]; }else cout << ch; } cout << endl; } }
### Prompt Please create a solution in cpp to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main(){ int n; char henkan[1000]; char ch,t_ch; while( cin >> n,n){ for(int i = 0 ; i < 1000 ; i++ )henkan[i] = '\0'; while(n--){ cin >> ch >> t_ch; henkan[ ch ] = t_ch; } cin >> n; while(n--){ cin >> ch; if(henkan[ ch ] != '\0'){ cout << henkan[ ch ]; }else cout << ch; } cout << endl; } } ```
#include<iostream> using namespace std; int main(){ char a,b,c[128],d[128]; int n,i; while(cin>>n){ if(n==0)break; for(i=0;i<128;i++)c[i]=d[i]=i; for(i=0;i<n;i++){cin>>a>>b;c[a]=d[b];} cin>>n; for(i=0;i<n;i++){cin>>a;cout<<c[a];} cout<<endl; } return 0; }
### Prompt Please provide a CPP coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> using namespace std; int main(){ char a,b,c[128],d[128]; int n,i; while(cin>>n){ if(n==0)break; for(i=0;i<128;i++)c[i]=d[i]=i; for(i=0;i<n;i++){cin>>a>>b;c[a]=d[b];} cin>>n; for(i=0;i<n;i++){cin>>a;cout<<c[a];} cout<<endl; } return 0; } ```
#include <iostream> using namespace std; int main() { int m,n; char from[100],to[100],x; while(cin >> n) { if(n == 0) break; for(int i=0;i<n;i++) { cin >> from[i] >> to[i]; } cin >> m; for(int i=0;i<m;i++) { cin >> x; for(int j=0;j<n;j++) { if(x == from[j]) { x = to[j]; break; } } cout << x; } cout << endl; } }
### Prompt Create a solution in CPP for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main() { int m,n; char from[100],to[100],x; while(cin >> n) { if(n == 0) break; for(int i=0;i<n;i++) { cin >> from[i] >> to[i]; } cin >> m; for(int i=0;i<m;i++) { cin >> x; for(int j=0;j<n;j++) { if(x == from[j]) { x = to[j]; break; } } cout << x; } cout << endl; } } ```
#include <cstdio> using namespace std; char conv[256]; int n,m; int main(){ char c; char s1[2]; char s2[2]; while(scanf("%d",&n) && n){ for(int i=0;i<256;i++){ conv[i] = i; } for(int i=0;i<n;i++){ scanf("%s %s",s1,s2); conv[*s1] = *s2; } scanf("%d",&m); for(int i=0;i<m;i++){ scanf("%s",s1); printf("%c",conv[*s1]); } printf("\n"); } }
### Prompt Generate a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <cstdio> using namespace std; char conv[256]; int n,m; int main(){ char c; char s1[2]; char s2[2]; while(scanf("%d",&n) && n){ for(int i=0;i<256;i++){ conv[i] = i; } for(int i=0;i<n;i++){ scanf("%s %s",s1,s2); conv[*s1] = *s2; } scanf("%d",&m); for(int i=0;i<m;i++){ scanf("%s",s1); printf("%c",conv[*s1]); } printf("\n"); } } ```
#include<iostream> #include<map> using namespace std; int main(){ char a,b,c; int n; for( ; ; ){ cin>> n; if(n==0)break; map<char,char> a2b; for(int i=0;i<n;i++){ cin>>a>>b; a2b[a]=b; } cin>>n; for(int i=0;i<n;i++){ cin>>c; if(a2b.count(c)==0) cout<<c; else cout<<a2b[c]; } cout<<endl; } return 0; }
### Prompt Create a solution in CPP for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<map> using namespace std; int main(){ char a,b,c; int n; for( ; ; ){ cin>> n; if(n==0)break; map<char,char> a2b; for(int i=0;i<n;i++){ cin>>a>>b; a2b[a]=b; } cin>>n; for(int i=0;i<n;i++){ cin>>c; if(a2b.count(c)==0) cout<<c; else cout<<a2b[c]; } cout<<endl; } return 0; } ```
#include <stdio.h> int main(void){ int n=0,m=0; while(scanf("%d",&n),n){ char change[100][2]; char s; for(int i=0;i<n;i++) scanf(" %c %c", &change[i][0], &change[i][1]); scanf("%d",&m); for(int j=0;j<m;j++){ scanf(" %c", &s); for(int k=0;k<n;k++){ if(s==change[k][0]){ s=change[k][1]; break; } } printf("%c", s); } printf("\n"); } return 0; }
### Prompt Please create a solution in CPP to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <stdio.h> int main(void){ int n=0,m=0; while(scanf("%d",&n),n){ char change[100][2]; char s; for(int i=0;i<n;i++) scanf(" %c %c", &change[i][0], &change[i][1]); scanf("%d",&m); for(int j=0;j<m;j++){ scanf(" %c", &s); for(int k=0;k<n;k++){ if(s==change[k][0]){ s=change[k][1]; break; } } printf("%c", s); } printf("\n"); } return 0; } ```
#include<iostream> #include<string> using namespace std; int main() { for(;;){ int n,m; string s1[1000],s2[1000]; string ans=""; string s; cin >> n; if(n==0)return 0; for(int i=0;i<n;i++){ cin >> s1[i] >> s2[i]; } cin >> m; for(int i=0;i<m;i++){ cin >> s; bool f=true; for(int j=0;j<n;j++){ if(s==s1[j]){ ans+=s2[j]; f=false; } } if(f)ans+=s; } cout << ans << "\n"; } return 0; }
### Prompt Create a solution in Cpp for the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<string> using namespace std; int main() { for(;;){ int n,m; string s1[1000],s2[1000]; string ans=""; string s; cin >> n; if(n==0)return 0; for(int i=0;i<n;i++){ cin >> s1[i] >> s2[i]; } cin >> m; for(int i=0;i<m;i++){ cin >> s; bool f=true; for(int j=0;j<n;j++){ if(s==s1[j]){ ans+=s2[j]; f=false; } } if(f)ans+=s; } cout << ans << "\n"; } return 0; } ```
#include <iostream> #include <map> #include <iterator> int main(){ int n; std::map< char, char > m; while( std::cin >> n, n ){ while( n-- ){ char c[2]; std::cin >> c[0] >> c[1]; m[c[0]] = c[1]; } std::cin >> n; while( n-- ){ char c; std::map< char, char >::iterator it; std::cin >> c; if( (it = m.find(c)) != m.end() ){ c = it->second; } std::cout << c; } std::cout << std::endl; m.clear(); } }
### Prompt Please provide a Cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <map> #include <iterator> int main(){ int n; std::map< char, char > m; while( std::cin >> n, n ){ while( n-- ){ char c[2]; std::cin >> c[0] >> c[1]; m[c[0]] = c[1]; } std::cin >> n; while( n-- ){ char c; std::map< char, char >::iterator it; std::cin >> c; if( (it = m.find(c)) != m.end() ){ c = it->second; } std::cout << c; } std::cout << std::endl; m.clear(); } } ```
#include<iostream> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; char m[99][2],z,y;int main(){int s,n;while(1){cin>>s;if(s==0)break;rep(i,s)cin>>m[i][0]>>m[i][1];cin>>n;rep(i,n){cin>>z;y=z;rep(j,s)if(m[j][0]==z)y=m[j][1];cout<<y;}cout<<endl;}return 0;}
### Prompt In cpp, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; char m[99][2],z,y;int main(){int s,n;while(1){cin>>s;if(s==0)break;rep(i,s)cin>>m[i][0]>>m[i][1];cin>>n;rep(i,n){cin>>z;y=z;rep(j,s)if(m[j][0]==z)y=m[j][1];cout<<y;}cout<<endl;}return 0;} ```
#include <bits/stdc++.h> using namespace std; typedef long long LL; #define REP(i,N) for(int i = 0; i < (int)N; i++) int main(){ int n; while(cin >> n){ if(n==0)break; map<char,char> mp; REP(i,n){ char from,to; cin >> from >> to; mp[from] = to; } int n; cin >> n; REP(i,n){ char c; cin >> c; if(mp[c] == 0){ cout << c; }else{ cout << mp[c]; } } cout << endl; } return 0; }
### Prompt Your challenge is to write a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <bits/stdc++.h> using namespace std; typedef long long LL; #define REP(i,N) for(int i = 0; i < (int)N; i++) int main(){ int n; while(cin >> n){ if(n==0)break; map<char,char> mp; REP(i,n){ char from,to; cin >> from >> to; mp[from] = to; } int n; cin >> n; REP(i,n){ char c; cin >> c; if(mp[c] == 0){ cout << c; }else{ cout << mp[c]; } } cout << endl; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n, m; string str; char c[256], t; while (cin >> n, n){ str = ""; for (int i = 0; i < 256; i++) c[i] = i; for (int i = 0; i < n; i++){ cin >> t; cin >> c[t]; } cin >> m; for (int i = 0; i < m; i++){ cin >> t; str += c[t]; } cout << str << endl; } }
### Prompt Please formulate a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n, m; string str; char c[256], t; while (cin >> n, n){ str = ""; for (int i = 0; i < 256; i++) c[i] = i; for (int i = 0; i < n; i++){ cin >> t; cin >> c[t]; } cin >> m; for (int i = 0; i < m; i++){ cin >> t; str += c[t]; } cout << str << endl; } } ```
#include <iostream> #include <string> using namespace std; int main() { while(1){ int a; cin >> a; if(a == 0){break;} char *b = new char [a]; char *c = new char [a]; for(int i = 0;i < a;i++){ cin >> b[i] >> c[i]; } int m; cin >> m; for(int i = 1;i <= m;i++){ char p; cin >> p; int ii = 0; while(ii < a){ if(p == b[ii]){ p = c[ii]; break; } ii++; } if(i == m){cout << p << endl;} else{cout << p;} } delete[] b; delete[] c; } return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <string> using namespace std; int main() { while(1){ int a; cin >> a; if(a == 0){break;} char *b = new char [a]; char *c = new char [a]; for(int i = 0;i < a;i++){ cin >> b[i] >> c[i]; } int m; cin >> m; for(int i = 1;i <= m;i++){ char p; cin >> p; int ii = 0; while(ii < a){ if(p == b[ii]){ p = c[ii]; break; } ii++; } if(i == m){cout << p << endl;} else{cout << p;} } delete[] b; delete[] c; } return 0; } ```
#include<iostream> using namespace std; int main(){ int i,j,n,x,l; char a[100001],b[100001],c[100001],m; while(true){ cin>>n; if(n==0){ break; } for(i=0;i<n;i++){ cin>>a[i]>>b[i]; } cin>>x; for(j=0;j<x;j++){ cin>>c[j]; } for(l=0;l<x;l++){ for(int k=0;k<n;++k){ if(c[l]==a[k]){ c[l]=b[k]; break; } } } for(int k=0;k<x;++k){ cout<<c[k]; } cout<<endl; } return 0; }
### Prompt Please provide a cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> using namespace std; int main(){ int i,j,n,x,l; char a[100001],b[100001],c[100001],m; while(true){ cin>>n; if(n==0){ break; } for(i=0;i<n;i++){ cin>>a[i]>>b[i]; } cin>>x; for(j=0;j<x;j++){ cin>>c[j]; } for(l=0;l<x;l++){ for(int k=0;k<n;++k){ if(c[l]==a[k]){ c[l]=b[k]; break; } } } for(int k=0;k<x;++k){ cout<<c[k]; } cout<<endl; } return 0; } ```
#include <iostream> #define REP(i, a, n) for(int i = a; i < n; i++) using namespace std; int n, m; char table[256]; char c, d; int main(void) { while(1) { cin >> n; if(n == 0) break; REP(i, 0, 256) table[i] = (char) i; REP(i, 0, n) { cin >> c >> d; table[c] = d; } cin >> m; REP(i, 0, m) { cin >> c; cout << table[c]; } cout << endl; } return 0; }
### Prompt Generate a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #define REP(i, a, n) for(int i = a; i < n; i++) using namespace std; int n, m; char table[256]; char c, d; int main(void) { while(1) { cin >> n; if(n == 0) break; REP(i, 0, 256) table[i] = (char) i; REP(i, 0, n) { cin >> c >> d; table[c] = d; } cin >> m; REP(i, 0, m) { cin >> c; cout << table[c]; } cout << endl; } return 0; } ```
#include <stdio.h> int main(){ int n,i,j,m,f; char a[256],b[256],x; while(1){ scanf("%d ",&n); if(n==0){ break; } for(i=0;i<n;i++){ scanf("%c %c ",&a[i],&b[i]); } scanf("%d ",&m); for(i=0;i<m;i++){ scanf("%c ",&x); f=0; for(j=0;j<n;j++){ if(x==a[j]){ printf("%c",b[j]); f=1; break; } } if(f==0){ printf("%c",x); } } printf("\n"); } return 0; }
### Prompt Construct a cpp code solution to the problem outlined: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <stdio.h> int main(){ int n,i,j,m,f; char a[256],b[256],x; while(1){ scanf("%d ",&n); if(n==0){ break; } for(i=0;i<n;i++){ scanf("%c %c ",&a[i],&b[i]); } scanf("%d ",&m); for(i=0;i<m;i++){ scanf("%c ",&x); f=0; for(j=0;j<n;j++){ if(x==a[j]){ printf("%c",b[j]); f=1; break; } } if(f==0){ printf("%c",x); } } printf("\n"); } return 0; } ```
#include <iostream> using namespace std; int main() { int n; char ch[256]; while(1) { for (int i=0; i<256; i++) ch[i]=i; cin >> n; if (n==0) break; for (int i=0; i<n; i++) { char a, b; cin >> a >> b; ch[a]=b; } int m; cin >> m; for (int i=0; i<m; i++) { char tmp; cin >> tmp; cout << ch[tmp]; } cout << endl; } }
### Prompt Please provide a CPP coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main() { int n; char ch[256]; while(1) { for (int i=0; i<256; i++) ch[i]=i; cin >> n; if (n==0) break; for (int i=0; i<n; i++) { char a, b; cin >> a >> b; ch[a]=b; } int m; cin >> m; for (int i=0; i<m; i++) { char tmp; cin >> tmp; cout << ch[tmp]; } cout << endl; } } ```
#include<iostream> #include<map> using namespace std; int main(){ for(;;){ int n, m; map<char, char> mpa; cin >> n; if(n == 0) break; for(int i = 1; i <= n; i++){ char a, b; cin >> a >> b; mpa[a] = b; } cin >> m; for(int i = 1; i <= m; i++){ char c; cin >> c; if(mpa.count(c)){ cout << mpa[c]; }else{ cout << c; } } cout << endl; } return 0; }
### Prompt In Cpp, your task is to solve the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<map> using namespace std; int main(){ for(;;){ int n, m; map<char, char> mpa; cin >> n; if(n == 0) break; for(int i = 1; i <= n; i++){ char a, b; cin >> a >> b; mpa[a] = b; } cin >> m; for(int i = 1; i <= m; i++){ char c; cin >> c; if(mpa.count(c)){ cout << mpa[c]; }else{ cout << c; } } cout << endl; } return 0; } ```
#include <iostream> using namespace std; int main() { int n, m; char *conv_from, *conv_to; while(cin >> n, n){ conv_from = new char [n]; conv_to = new char [n]; for(int i=0; i<n; i++){ cin >> conv_from[i] >> conv_to[i]; } cin >> m; for(; m; m--){ char c; cin >> c; for(int i=0; i<n; i++){ if(c == conv_from[i]){ c = conv_to[i]; break; } } cout << c; } cout << endl; } return 0; }
### Prompt Please formulate a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int main() { int n, m; char *conv_from, *conv_to; while(cin >> n, n){ conv_from = new char [n]; conv_to = new char [n]; for(int i=0; i<n; i++){ cin >> conv_from[i] >> conv_to[i]; } cin >> m; for(; m; m--){ char c; cin >> c; for(int i=0; i<n; i++){ if(c == conv_from[i]){ c = conv_to[i]; break; } } cout << c; } cout << endl; } return 0; } ```
#include <stdio.h> #include <map> using namespace std; int main(){ while(1){ map<char, char> data; int n,i; scanf("%d", &n); if(n==0) break; char a,b; for(i=0;i<n;i++) { scanf(" %c %c", &a, &b); data.insert(pair<char,char>(a,b)); } scanf("%d", &n); for(i=0;i<n;i++){ scanf(" %c", &a); if(data.find(a) != data.end()) printf("%c", data[a]); else printf("%c", a); } puts(""); } }
### Prompt Please formulate a Cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <stdio.h> #include <map> using namespace std; int main(){ while(1){ map<char, char> data; int n,i; scanf("%d", &n); if(n==0) break; char a,b; for(i=0;i<n;i++) { scanf(" %c %c", &a, &b); data.insert(pair<char,char>(a,b)); } scanf("%d", &n); for(i=0;i<n;i++){ scanf(" %c", &a); if(data.find(a) != data.end()) printf("%c", data[a]); else printf("%c", a); } puts(""); } } ```
#include <iostream> #include <map> #include <algorithm> #define rep(i, n) for(int i = 0; i < (n); ++i) using namespace std; int n; map<char, char> c; int main(){ while(1){ cin >> n; if(!n){ break; } rep(i, n){ char a, b; cin >> a >> b; c[a] = b; } int q; cin >> q; rep(i, q){ char p; cin >> p; cout << (c[p] ? c[p] : p); } cout << endl; c.clear(); } return 0; }
### Prompt Your task is to create a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <map> #include <algorithm> #define rep(i, n) for(int i = 0; i < (n); ++i) using namespace std; int n; map<char, char> c; int main(){ while(1){ cin >> n; if(!n){ break; } rep(i, n){ char a, b; cin >> a >> b; c[a] = b; } int q; cin >> q; rep(i, q){ char p; cin >> p; cout << (c[p] ? c[p] : p); } cout << endl; c.clear(); } return 0; } ```
#include <iostream> using namespace std; int n,m; char cha[2][100]; char str[100000000]; void solve() { for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ if(str[i] == cha[0][j]){ str[i] = cha[1][j]; break; } } cout << str[i]; } cout << endl; } int main() { cin >> n; while(n){ for(int i=0;i<n;i++){ cin >> cha[0][i] >> cha[1][i]; } cin >> m; for(int i=0;i<m;i++){ cin >> str[i]; } solve(); cin >> n; } return 0; }
### Prompt Generate a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> using namespace std; int n,m; char cha[2][100]; char str[100000000]; void solve() { for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ if(str[i] == cha[0][j]){ str[i] = cha[1][j]; break; } } cout << str[i]; } cout << endl; } int main() { cin >> n; while(n){ for(int i=0;i<n;i++){ cin >> cha[0][i] >> cha[1][i]; } cin >> m; for(int i=0;i<m;i++){ cin >> str[i]; } solve(); cin >> n; } return 0; } ```
#include<iostream> #include<map> using namespace std; int N,M; void solve(){ map<char,char>mp; for(int i = 0 ; i < N ; i++){ char a,b; cin >> a >> b; mp[a] = b; } cin >> M; for(int i = 0 ; i < M ; i++){ char c; cin >> c; if(mp.find(c) != mp.end())cout << mp[c]; else cout << c; } cout << endl; } int main(){ while(cin >> N,N)solve(); }
### Prompt Develop a solution in cpp to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include<iostream> #include<map> using namespace std; int N,M; void solve(){ map<char,char>mp; for(int i = 0 ; i < N ; i++){ char a,b; cin >> a >> b; mp[a] = b; } cin >> M; for(int i = 0 ; i < M ; i++){ char c; cin >> c; if(mp.find(c) != mp.end())cout << mp[c]; else cout << c; } cout << endl; } int main(){ while(cin >> N,N)solve(); } ```
#import<iostream> #define z std::cin>> int main(){for(int n;z n,n;puts("")){char a,b,d[256]={};for(;n--;d[a]=b-a)z a>>b;for(z n;n--;putchar(a+d[a]))z a;}}
### Prompt Your task is to create a CPP solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #import<iostream> #define z std::cin>> int main(){for(int n;z n,n;puts("")){char a,b,d[256]={};for(;n--;d[a]=b-a)z a>>b;for(z n;n--;putchar(a+d[a]))z a;}} ```
#include <iostream> #include <vector> using namespace std; int main(){ while(1){ int n; cin >> n; if(n==0) break; vector<char> conv(128); for(int i=0; i<128; i++) conv[i]=i; for(int i=0; i<n; i++){ char a,b; cin >> a >> b; conv[a] = b; } int m; cin >> m; string ret=""; for(int i=0; i<m; i++){ char a; cin >> a; ret += conv[a]; } cout << ret << endl; } return 0; }
### Prompt Please formulate a cpp solution to the following problem: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one before and one after, with a space in between. The conversion method is to convert the character before the line in the conversion table to the character after each time it appears in the data and output it. It is converted only once, and even if the converted character becomes the character to be converted again, it is not converted. Characters that do not appear in the conversion table are not converted and are output as they are. In the input file, the conversion table (first n + 1 line) is followed by the data to be converted (n + 2nd line and after). The number of lines in the conversion table is n on the first line, each line of the following n lines is two characters with a blank, and then the number of lines of data to be converted on the n + second line m, and each line of the following m lines. Is a single character. Let m ≤ 105. Output should be one line without blanks or line breaks as in the output example. Input example --- 3 A a 0 5 5 4 Ten A B C 0 1 Four Five a b b A Output example aBC5144aba input The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5. output For each data set, the converted character string is output on one line. Example Input 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 0 Output aBC5144aba aBC5144aba ### Response ```cpp #include <iostream> #include <vector> using namespace std; int main(){ while(1){ int n; cin >> n; if(n==0) break; vector<char> conv(128); for(int i=0; i<128; i++) conv[i]=i; for(int i=0; i<n; i++){ char a,b; cin >> a >> b; conv[a] = b; } int m; cin >> m; string ret=""; for(int i=0; i<m; i++){ char a; cin >> a; ret += conv[a]; } cout << ret << endl; } return 0; } ```