Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. ifstream f("date.in");
  5. ofstream g("date.out");
  6.  
  7. int nrvoc(char s[])
  8. {
  9.     int c=0;
  10.     for(int i=0;i<strlen(s);++i){
  11.         if(strchr("AEIOUaeiou",s[i]))c++;
  12.     }
  13.     return c;
  14. }
  15.  
  16. int main()
  17. {
  18.     int c=0;
  19.     char s[256];
  20.     char cuv[140][256];
  21.     f.get(s,255);
  22.     char *p=strtok(s," ");
  23.     char vex[255];
  24.  
  25.  
  26.     while(p){
  27.         c++;
  28.         strcpy(cuv[c],p);
  29.         strcpy(vex,p);
  30.         p=strtok(nullptr," ");
  31.     }
  32.     for(int i=1;i<=c;++i){
  33.         for(int j=i+1;j<=c;++j){
  34.             if(strcmp(cuv[i],cuv[j])>0){
  35.                 char aux[255];
  36.                 strcpy(aux,cuv[i]);
  37.                 strcpy(cuv[i],cuv[j]);
  38.                 strcpy(cuv[j],aux);
  39.             }
  40.         }
  41.     }
  42.     for(int i=1;i<=c;++i)
  43.         g<<cuv[i]<<endl;
  44.  
  45.     char maxvoc[255];
  46.     strcpy(maxvoc,cuv[1]);
  47.     for(int i=2;i<=c;++i){
  48.         if(nrvoc(maxvoc)<nrvoc(cuv[i])){
  49.             strcpy(maxvoc,cuv[i]);
  50.         }
  51.         if(nrvoc(maxvoc)==nrvoc(cuv[i])){
  52.             if(strlen(cuv[i])<strlen(maxvoc))
  53.                 strcpy(maxvoc,cuv[i]);
  54.         }
  55.     }
  56.     g<<endl<<maxvoc<<endl;
  57.  
  58.     int nr=0;
  59.     for(int i=1;i<=c;++i){
  60.         if(nrvoc(cuv[i])>strlen(cuv[i])-nrvoc(cuv[i]))
  61.             nr++;
  62.     }
  63.     g<<nr<<endl;
  64.  
  65.     for(int i=1;i<strlen(vex);++i){
  66.         for(int j=i;j<strlen(vex);++j)
  67.             g<<vex[j]; ///vex e ultimul cuvant
  68.         g<<endl;
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement