Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.17 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdbool.h>
  3. #include<string.h>
  4.  
  5. int m = 0;
  6.  
  7. bool lex(char *input1, char *input2)
  8. {
  9.     printf("%s and %s is entered\n\n", input1, input2);
  10.     if(input1[m] > input2[m])
  11.     {
  12.         m = 0;
  13.         printf("%s is bigger than %s\n\n", input1, input2);
  14.         return strcmp(input1,input2);
  15.     }
  16.     else if (input1[m] == input2[m])
  17.     {
  18.         printf("%s is is equal to %s\n\n", input1, input2);
  19.         m++;
  20.         return lex(&input1,&input2);
  21.     }
  22. }
  23. int main()
  24. {
  25.     int i,j;
  26.     char input[100][1000], temp[1000];
  27. //    sort(&input, &input + 9, lex);
  28. //    scanf("%s %s",&input[0], input[1]);
  29. //    printf("%s & %s : %d", input[0], input[1], strcmp(input[0],input[1]));
  30.     for(i=0; i<5; i++)
  31.         scanf("%s",&input[i]);
  32.     for(i=0; i<5; i++)
  33.     {
  34.         for(j=0; j<i; j++)
  35.         {
  36.             if(lex(&input[i], &input[j]) > 0)
  37.             {
  38.                 //swap(input[i],input[j]);
  39.                 strcpy(temp,input[i]);
  40.                 strcpy(input[i],input[j]);
  41.                 strcpy(input[j],temp);
  42.             }
  43.         }
  44.     }
  45.     for(i=0; i<5; i++)
  46.         printf("%s\n", input[i]);
  47.  
  48.     return 0;
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement