Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define CUVINTE 100
- #define LUNGIME 20
- void ordoneaza(char **s, int n)
- {
- int i, j;
- char aux[LUNGIME];
- for (i = 0; i < n-1; i++)
- {
- for (j = i+1; j < n; j++)
- {
- if (strcmp(s[i], s[j]) > 0)
- {
- strcpy(aux, s[i]);
- strcpy(s[i], s[j]);
- strcpy(s[j], aux);
- }
- }
- }
- }
- int main(void)
- {
- char **s, *p, aux[100];
- int i, k = 0;
- s = (char **) malloc(CUVINTE * sizeof(char *));
- if (!s)
- exit(1);
- for (i = 0; i < CUVINTE; i++)
- {
- s[i] = (char *) malloc(LUNGIME * sizeof(char));
- if (!s[i])
- {
- free(s);
- exit(1);
- }
- }
- fgets(aux, 100, stdin);
- while (aux[0] != '\n')
- {
- p = strtok(aux, " \n");
- while (p)
- {
- strcpy(s[k], p);
- k ++;
- p = strtok(NULL, " \n");
- }
- fgets(aux, 100, stdin);
- }
- for (i = 0; i < k; i++)
- {
- if (strchr("aeiouAEIOU", s[i][0]) && !strchr("aeiouAEIOU", s[i][strlen(s[i]) - 1]))
- printf("%s\n", s[i]);
- }
- ordoneaza(s, k);
- for (i = 0; i < k; i++)
- printf("%s\n", s[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment