Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int nr_voc(char s[])
- {
- int nrvoc=0;
- int i=0;
- while(s[i]!=0)
- {
- if(strchr("aeiouAEIOU",s[i]))
- ++nrvoc;
- ++i;
- }
- return nrvoc;
- }
- bool e_palindrom(char s[])
- {
- unsigned int L=strlen(s);
- for(unsigned int i=0;i<L/2;++i)
- if(s[i]!=s[L-i-1])
- return false;
- return true;
- }
- int nr_lit_dist(char s[])
- {
- int nr=0,F[123];
- for(int i=65;i<=122;++i)
- F[i]=0;
- for(unsigned int i=0;i<strlen(s);++i)
- ++F[(int)s[i]];
- for(int i=65;i<=122;++i)
- if(F[i])
- ++nr;
- return nr;
- }
- int main()
- {
- int n;
- cin>>n;
- char cuv[101][21];
- int LitD[101],nrvoc=0;
- unsigned int MAX=0;
- for(int i=0;i<n;++i)
- {
- cin>>cuv[i];
- if(strlen(cuv[i])>MAX)
- MAX=strlen(cuv[i]);
- nrvoc+=nr_voc(cuv[i]);
- LitD[i]=nr_lit_dist(cuv[i]);
- }
- for(int i=n-1;i>=0;--i)
- if(strlen(cuv[i])==MAX)
- {
- cout<<cuv[i]<<'\n';
- break;
- }
- cout<<nrvoc<<'\n';
- for(int i=0;i<n;++i)
- if(e_palindrom(cuv[i]))
- cout<<cuv[i]<<' ';
- cout<<'\n';
- char s[21];
- for(int i=0;i<n-1;++i)
- for(int j=i+1;j<n;++j)
- if(LitD[i]<=LitD[j])
- {
- if(LitD[i]==LitD[j])
- {
- if(strcmp(cuv[i],cuv[j])==1)
- {
- swap(LitD[i],LitD[j]);
- strcpy(s,cuv[i]);
- strcpy(cuv[i],cuv[j]);
- strcpy(cuv[j],s);
- }
- }
- else
- {
- swap(LitD[i],LitD[j]);
- strcpy(s,cuv[i]);
- strcpy(cuv[i],cuv[j]);
- strcpy(cuv[j],s);
- }
- }
- for(int i=0;i<n;++i)
- cout<<cuv[i]<<' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement