Vprento

Сортирање на зборови

Dec 11th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7.     char a[10][50], temp[50];
  8.     int i, j;
  9.     for(i=0;i<10;i++)
  10.     {
  11.         fgets(a[i], 49, stdin);
  12.     }
  13.     for(i=0;i<10;i++)
  14.     {
  15.         for(j=0;j<10-1;j++)
  16.         {
  17.             if((strcmp(a[j], a[j+1]))>0)
  18.             {
  19.                 strcpy(temp, a[j]);
  20.                 strcpy(a[j], a[j+1]);
  21.                 strcpy(a[j+1], temp);
  22.             }
  23.         }
  24.     }
  25.     printf("\n");
  26.     for(i=0;i<10;i++)
  27.     {
  28.         printf("%s", a[i]);
  29.     }
  30.     return 0;
  31. }
Add Comment
Please, Sign In to add comment