Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. char str[50000][35], t[50000];
  4. int main()
  5. {
  6.     //clrscr();
  7.  
  8.     //cout << "Enter any five string (name) : ";
  9.     int T;
  10.     cin >> T;
  11.  
  12.     while (T--)
  13.     {
  14.         int i, j, n;
  15.         cin >> n;
  16.         for (i = 0; i < n; i++)
  17.         {
  18.             cin >> str[i];
  19.         }
  20.         for (i = 1; i < n; i++)
  21.         {
  22.             for (j = 1; j < n; j++)
  23.             {
  24.                 if (strcmp(str[j - 1], str[j]) > 0)
  25.                 {
  26.                     strcpy(t, str[j - 1]);
  27.                     strcpy(str[j - 1], str[j]);
  28.                     strcpy(str[j], t);
  29.                 }
  30.             }
  31.         }
  32.  
  33.         /*cout << endl;
  34.     for (i = 0; i < n; i++)
  35.     {
  36.         cout << str[i] << "\n";
  37.     }*/
  38.  
  39.         int q;
  40.         cin >> q;
  41.         getchar();
  42.  
  43.         while (q--)
  44.         {
  45.             char que[10];
  46.             gets(que);
  47.             for (int z = 0; z < n; z++)
  48.             {
  49.                 if (que[0] == str[z][0])
  50.                 {
  51.                     cout << str[z] << endl;
  52.                     str[z][0] = '0';
  53.                     break;
  54.                 }
  55.                 else if (z == n - 1)
  56.                     cout << "Already Mastered" << endl;
  57.             }
  58.         }
  59.     }
  60.  
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement