Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. /* Ucitati niz od 10 stringova. Nakon svakog ucitavanja string pohraniti
  2. u odgovarajuce mjesto u nizu tako da stringovi budu poredani abecednim redom! */
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #define N 10
  8.  
  9. int main(void) {
  10.  
  11. char string[10][50];
  12. char pom[50];
  13. int i,j;
  14.  
  15.  
  16. printf("Unesite niz od 10 stringova:\n");
  17.  
  18. for(i=0;i<10;i++){
  19. fflush(stdin);
  20. gets(string[i]);
  21. if(strcmp(string[i],string[i+1])>0){
  22. strcpy(pom,string[i]);
  23. strcpy(string[i],string[i+1]);
  24. strcpy(string[i+1],pom);
  25. }
  26.  
  27. }
  28.  
  29. for(i=0;i<10;i++){
  30.  
  31. putchar('\n');
  32. puts(string[i]);
  33. }
  34.  
  35.  
  36. return 0;
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement