fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. const int MAX_SIZE = 100;
  6. const int MAX_STRING = 20;
  7.  
  8. int noVow(char s[]) {
  9. char vowels[] = "aeiouAEIOU";
  10. int lenght = strlen(s), noVowels = 0;
  11. for (int i = 0; i < lenght; ++i) {
  12. if (strchr(vowels, s[i])) {
  13. ++noVowels;
  14. }
  15. }
  16. return noVowels;
  17. }
  18.  
  19. bool isBigger(char s1[], char s2[]) {
  20. return (s1[0] > s2[0]);
  21. }
  22.  
  23. void change(char str1[], char str2[]) {
  24. char auxStr[MAX_STRING + 1];
  25. strcpy(auxStr, str1);
  26. strcpy(str1, str2);
  27. strcpy(str2, auxStr);
  28. }
  29.  
  30. int main()
  31. { char str[MAX_SIZE + 1][MAX_SIZE + 1];
  32. int nrStr = 0;
  33. while (cin >> str[nrStr] && nrStr < MAX_STRING + 1) {
  34. ++nrStr;
  35. }
  36. for (int i = 0; i < nrStr; ++i) {
  37. for (int j = i + 1; j < nrStr; ++j) {
  38. if (noVow(str[i]) > noVow(str[j])) {
  39. change(str[i], str[j]);
  40. } else if (noVow(str[i]) == noVow(str[j]) && isBigger(str[i], str[j]) != 0) {
  41. change(str[i], str[j]);
  42. }
  43. }
  44. }
  45. for (int i = 0; i < nrStr; ++i) {
  46. cout << str[i] << "\n";
  47. }
  48. return 0;
  49. }
Success #stdin #stdout 0.01s 5288KB
stdin
ana are mere frumoase si dulci
stdout
si
are
ana
dulci
mere
frumoase