Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstring>
  3. #include<cstdio>
  4.  
  5. using namespace std;
  6.  
  7. class String
  8. {
  9.  
  10. public:
  11. char word[11];
  12. };
  13.  
  14. int main()
  15. {
  16. int n,m;
  17. String w[3000][2], lec[3000];
  18. cin>>n>>m;
  19.  
  20. if(n<1 || n>3000) return 0;
  21. if(m<1 || m>3000) return 0;
  22.  
  23. for(int i=0; i<m; i++)
  24. {
  25. for(int j=0; j<2; j++)
  26. {
  27. scanf("%s", w[i][j].word);
  28. }
  29. }
  30.  
  31. for(int i=0; i<n; i++)
  32. {
  33. scanf("%s", lec[i].word);
  34.  
  35. for(int k=0; k<m; k++)
  36. {
  37. if(!(strcmp(lec[i].word, w[k][0].word)) || !(strcmp(lec[i].word, w[k][1].word)))
  38. {
  39. if(strlen(w[k][1].word)>strlen(w[k][0].word)) cout<<w[k][0].word<<" ";
  40. else if(strlen(w[k][1].word)<strlen(w[k][0].word)) cout<<w[k][1].word<<" ";
  41. else
  42. {
  43. for(int j=0; w[k][0].word[j]; j++)
  44. {
  45. if(w[k][0].word[j]>w[k][1].word[j]) {cout<<w[k][1].word<<" "; break;}
  46. else if(w[k][0].word[j]<w[k][1].word[j]) {cout<<w[k][0].word<<" "; break;}
  47. else continue;
  48. }
  49. }
  50. }
  51.  
  52. }
  53. }
  54.  
  55. return 0;
  56.  
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement