Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- #include <conio.h>
- #define TF 3
- #define LIM 51
- int main()
- {
- char nomes[TF][LIM], i, aux[LIM], pos, j, k, achou;
- for(i = 0; i < TF; i++)
- {
- fflush(stdin);
- fgets(aux, LIM, stdin);
- pos = 0;
- for(k = 0; k < i; k++)
- {
- achou = 0;
- for(j = 0; nomes[k][j] != '\0' && achou == 0; j++)
- if(nomes[k][j] != aux[j])
- if(toupper(aux[j]) > toupper(nomes[k][j]))
- {
- pos++;
- achou = 1;
- }
- else if(aux[j] < nomes[k][j])
- achou = 1;
- }
- for(j = i; j > pos; j--)
- strcpy(nomes[j], nomes[j - 1]);
- strcpy(nomes[pos], aux);
- }
- for(i = 0; i < TF; i++)
- printf("%s", nomes[i]);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement