Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(){
- int i=0;
- char nome[3][30], aux[30];
- for(i=0;i<3;i++){
- printf("Por favor,entre com o nome %d:",i+1);
- fgets(nome[i],30,stdin);}
- int j;
- for(j=1;j<3;j++){
- strcpy(aux,nome[j]);
- i = j-1;
- while(i>=0&&strcmp(nome[i],aux)>0){
- strcpy(nome[i+1],nome[i]);
- i--;}
- strcpy(nome[i+1],aux);
- }
- printf("\n\nNomes em ordem alfabetica: \n");
- for(i=0;i<3;i++){
- printf("%do nome-> %s",i+1,nome[i]);
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment