Advertisement
ChrisPetrovski

Сортирање на зборови [Лаб 9.3]

Dec 11th, 2017
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main() {
  4.     void swap ( char *str1, char *str2);
  5.     int i,k,j=0;
  6.     char temp[10][50];
  7.     char zborovi[10][50];
  8.     char c;
  9.     for(i=0;i<10;i++){
  10.             gets(zborovi[i]);
  11.     }
  12.    for (i = 0; i < 10; i++) {
  13.         for (j = 0; j < 10-i; j++) {
  14.             if (strcmp(zborovi[j], zborovi[j + 1]) > 0) {
  15.                 strcpy(temp, zborovi[j]);
  16.                 strcpy(zborovi[j], zborovi[j + 1]);
  17.                 strcpy(zborovi[j + 1], temp);
  18.             }
  19.         }
  20.     }
  21.         for(j=0;j<10;j++)
  22.                 printf("%s\n",zborovi[j]);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement