Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdbool.h>
- #include<string.h>
- int m = 0;
- bool lex(char *input1, char *input2)
- {
- printf("%s and %s is entered\n\n", input1, input2);
- if(input1[m] > input2[m])
- {
- m = 0;
- printf("%s is bigger than %s\n\n", input1, input2);
- return strcmp(input1,input2);
- }
- else if (input1[m] == input2[m])
- {
- printf("%s is is equal to %s\n\n", input1, input2);
- m++;
- return lex(&input1,&input2);
- }
- }
- int main()
- {
- int i,j;
- char input[100][1000], temp[1000];
- // sort(&input, &input + 9, lex);
- // scanf("%s %s",&input[0], input[1]);
- // printf("%s & %s : %d", input[0], input[1], strcmp(input[0],input[1]));
- for(i=0; i<5; i++)
- scanf("%s",&input[i]);
- for(i=0; i<5; i++)
- {
- for(j=0; j<i; j++)
- {
- if(lex(&input[i], &input[j]) > 0)
- {
- //swap(input[i],input[j]);
- strcpy(temp,input[i]);
- strcpy(input[i],input[j]);
- strcpy(input[j],temp);
- }
- }
- }
- for(i=0; i<5; i++)
- printf("%s\n", input[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement