Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstring>
- #include<cstdio>
- using namespace std;
- class String
- {
- public:
- char word[11];
- };
- int main()
- {
- int n,m;
- String w[3000][2], lec[3000];
- cin>>n>>m;
- if(n<1 || n>3000) return 0;
- if(m<1 || m>3000) return 0;
- for(int i=0; i<m; i++)
- {
- for(int j=0; j<2; j++)
- {
- scanf("%s", w[i][j].word);
- }
- }
- for(int i=0; i<n; i++)
- {
- scanf("%s", lec[i].word);
- for(int k=0; k<m; k++)
- {
- if(!(strcmp(lec[i].word, w[k][0].word)) || !(strcmp(lec[i].word, w[k][1].word)))
- {
- if(strlen(w[k][1].word)>strlen(w[k][0].word)) cout<<w[k][0].word<<" ";
- else if(strlen(w[k][1].word)<strlen(w[k][0].word)) cout<<w[k][1].word<<" ";
- else
- {
- for(int j=0; w[k][0].word[j]; j++)
- {
- if(w[k][0].word[j]>w[k][1].word[j]) {cout<<w[k][1].word<<" "; break;}
- else if(w[k][0].word[j]<w[k][1].word[j]) {cout<<w[k][0].word<<" "; break;}
- else continue;
- }
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement