daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. int main(int argc, char *argv[]) {
  7.     char niz[100][100];
  8.     int i,n=0;
  9.     printf("Niz imena\n");
  10.     do
  11.     {
  12.         gets(niz[n]);
  13.     }
  14.     while(strlen(niz[n++]) > 0);
  15.     sort(niz,n);
  16.     for(i=0;i<n;i++)
  17.     {
  18.         puts(niz[i]);
  19.     }
  20.     return 0;
  21. }
  22. void sort(char niz[100][100],int n)
  23. {
  24.     int i,j;
  25.     char tmp[100];
  26.     for(i=0;i<n;i++)
  27.     {
  28.         for(j=i;j<n;j++)
  29.         {
  30.             if(strcmp(niz[i],niz[j]) > 0)
  31.             {
  32.                 strcpy(tmp,niz[i]);
  33.                 strcpy(niz[i],niz[j]);
  34.                 strcpy(niz[j],tmp);
  35.             }
  36.         }
  37.     }
  38.    
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top