Advertisement
a53

SirC 1

a53
Nov 16th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int nr_voc(char s[])
  6. {
  7. int nrvoc=0;
  8. int i=0;
  9. while(s[i]!=0)
  10. {
  11. if(strchr("aeiouAEIOU",s[i]))
  12. ++nrvoc;
  13. ++i;
  14. }
  15. return nrvoc;
  16. }
  17.  
  18. bool e_palindrom(char s[])
  19. {
  20. unsigned int L=strlen(s);
  21. for(unsigned int i=0;i<L/2;++i)
  22. if(s[i]!=s[L-i-1])
  23. return false;
  24. return true;
  25. }
  26.  
  27. int nr_lit_dist(char s[])
  28. {
  29. int nr=0,F[123];
  30. for(int i=65;i<=122;++i)
  31. F[i]=0;
  32. for(unsigned int i=0;i<strlen(s);++i)
  33. ++F[(int)s[i]];
  34. for(int i=65;i<=122;++i)
  35. if(F[i])
  36. ++nr;
  37. return nr;
  38. }
  39.  
  40. int main()
  41. {
  42. int n;
  43. cin>>n;
  44. char cuv[101][21];
  45. int LitD[101],nrvoc=0;
  46. unsigned int MAX=0;
  47. for(int i=0;i<n;++i)
  48. {
  49. cin>>cuv[i];
  50. if(strlen(cuv[i])>MAX)
  51. MAX=strlen(cuv[i]);
  52. nrvoc+=nr_voc(cuv[i]);
  53. LitD[i]=nr_lit_dist(cuv[i]);
  54. }
  55. for(int i=n-1;i>=0;--i)
  56. if(strlen(cuv[i])==MAX)
  57. {
  58. cout<<cuv[i]<<'\n';
  59. break;
  60. }
  61. cout<<nrvoc<<'\n';
  62. for(int i=0;i<n;++i)
  63. if(e_palindrom(cuv[i]))
  64. cout<<cuv[i]<<' ';
  65. cout<<'\n';
  66. char s[21];
  67. for(int i=0;i<n-1;++i)
  68. for(int j=i+1;j<n;++j)
  69. if(LitD[i]<=LitD[j])
  70. {
  71. if(LitD[i]==LitD[j])
  72. {
  73. if(strcmp(cuv[i],cuv[j])==1)
  74. {
  75. swap(LitD[i],LitD[j]);
  76. strcpy(s,cuv[i]);
  77. strcpy(cuv[i],cuv[j]);
  78. strcpy(cuv[j],s);
  79. }
  80. }
  81. else
  82. {
  83. swap(LitD[i],LitD[j]);
  84. strcpy(s,cuv[i]);
  85. strcpy(cuv[i],cuv[j]);
  86. strcpy(cuv[j],s);
  87. }
  88. }
  89. for(int i=0;i<n;++i)
  90. cout<<cuv[i]<<' ';
  91. return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement