Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- int main()
- {
- char s[256], v[101][30], *p, voc[] = "aeiouAEIOU", t[30];
- int n = 0, i, j, a[101] = {0}, nr = 0, aux;
- cin.getline(s, 256);
- p = strtok(s , " ");
- while(p != NULL)
- {
- n++;
- strcpy(v[n], p);
- for(i = 0; i < strlen(p); i++)
- if(strchr(voc, p[i]))
- nr++;
- a[n] = nr;
- nr = 0;
- p = strtok(NULL, " ");
- }
- for(i = 1; i < n; i++)
- for(j = i + 1; j <= n; j++)
- {
- if(a[i] < a[j])
- {
- aux = a[j];
- a[j] = a[i];
- a[i] = aux;
- strcpy(t, v[i]);
- strcpy(v[i], v[j]);
- strcpy(v[j] , t);
- }
- else if(a[i] == a[j])
- if(strlen(v[i]) < strlen(v[j]))
- {
- strcpy(t, v[i]);
- strcpy(v[i], v[j]);
- strcpy(v[j] , t);
- }
- else if(strlen(v[i]) == strlen(v[j]) && strcmp(v[i], v[j]) == 1)
- {
- strcpy(t, v[i]);
- strcpy(v[i], v[j]);
- strcpy(v[j] , t);
- }
- }
- for(i = 1; i <= n; i++)
- cout << v[i] << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement