Advertisement
Guest User

scrabble_100

a guest
Nov 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. ifstream fin("scrabble.in");
  5. ofstream fout("scrabble.out");
  6. int n, lv, lc;
  7. char cuvv[20][3], cuvc[20][3], voc[]="AEIOU";
  8. char s[20], smax[20];
  9.  
  10. int main()
  11. {
  12.     int i, j;
  13.     fin>>n;
  14.     fin.get();
  15.     fin>>s;
  16.     for(i=1;i<=n;i++)
  17.     {
  18.         if(strcmp(s,smax)!=0)
  19.         {
  20.             if(strchr(voc,s[1]))
  21.             {
  22.                 lc++;
  23.                 strcpy(cuvc[lc], s);
  24.             }
  25.             else
  26.             {
  27.                 lv++;
  28.                 strcpy(cuvv[lv],s);
  29.             }
  30.         }
  31.         strcpy(smax,s);
  32.         fin>>s;
  33.     }
  34.     for(i=1;i<lv;i++)
  35.         for(j=i+1;j<=lv;j++)
  36.             if(strcmp(cuvv[i],cuvv[j])<0)
  37.                 swap(cuvv[i],cuvv[j]);
  38.     for(i=1;i<lc;i++)
  39.         for(j=i+1;j<=lc;j++)
  40.             if(strcmp(cuvc[i],cuvc[j])<0)
  41.                 swap(cuvc[i],cuvc[j]);
  42.     if(lv>lc)
  43.     {
  44.         for(i=1;i<=lv;i++)
  45.             fout<<cuvv[i];
  46.         return 0;
  47.     }
  48.     else if(lv==lc)
  49.     {
  50.         if(cuvc[1][0]>cuvv[1][0])
  51.         {
  52.             for(i=1;i<=lc;i++)
  53.                 fout<<cuvc[i];
  54.             return 0;
  55.         }
  56.         else
  57.         {
  58.             for(i=1;i<=lv;i++)
  59.                 fout<<cuvv[i];
  60.              return 0;
  61.         }
  62.     }
  63.     else
  64.         for(i=1;i<=lc;i++)
  65.             fout<<cuvc[i];
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement