Advertisement
Drowze

07 Strings 08

May 14th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. /*Faça  um  programa  que  receba  uma  sequência  de  caracteres  e  as  ordene  dentro  do
  2. vetor. Ao final, imprima o vetor ordenado.*/
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #define MAX 15
  8.  
  9. void main()
  10. {
  11.     char string[MAX],aux;
  12.     int i=0,j=0;
  13.  
  14.     printf("Digite uma string e ordenarei suas letras alfabeticamente\n");
  15.     gets(string);
  16.  
  17.     for(i=0;string[i];i++) for(j=i+1;string[j];j++) if(string[i]>string[j]){
  18.         aux=string[i];
  19.         string[i]=string[j];
  20.         string[j]=aux;
  21.     }
  22.  
  23.     printf("%s",string);
  24.  
  25.     system("Pause");
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement