SHOW:
|
|
- or go back to the newest paste.
| 1 | #include<stdio.h> | |
| 2 | #include<string.h> | |
| 3 | ||
| 4 | ||
| 5 | int main(void) | |
| 6 | {
| |
| 7 | ||
| 8 | ||
| 9 | char temp[1000] ; int i ; | |
| 10 | ||
| 11 | char text[7][80]={ "Ahen" , "innn" , "the" , "course" , "ooof" , "human" , "events" } ;
| |
| 12 | ||
| 13 | char TEXT[7][80] ; | |
| 14 | ||
| 15 | for(i=0 ; i<7 ; i++) | |
| 16 | {
| |
| 17 | strcpy(TEXT[i],text[i]) ; | |
| 18 | } | |
| 19 | ||
| 20 | ||
| 21 | ||
| 22 | for(i=0 ; i<7 ; i++) | |
| 23 | {
| |
| 24 | strlwr(text[i]) ; | |
| 25 | } | |
| 26 | ||
| 27 | char a[1000] ; | |
| 28 | ||
| 29 | gets(a) ; int c=0; | |
| 30 | ||
| 31 | strlwr(a) ; | |
| 32 | ||
| 33 | for(i=0 ; i<7 ; i++) | |
| 34 | {
| |
| 35 | if(strcmp(a,text[i])==0) | |
| 36 | {
| |
| 37 | {printf("found\nindex:%d\n",i) ;c++;}
| |
| 38 | } | |
| 39 | } | |
| 40 | ||
| 41 | if(c==0) | |
| 42 | {
| |
| 43 | printf("not found\n") ;
| |
| 44 | } | |
| 45 | ||
| 46 | ||
| 47 | int j ; | |
| 48 | ||
| 49 | printf("\nSorted:\n\n") ;
| |
| 50 | ||
| 51 | for(i=0 ; i<7 ; i++) | |
| 52 | {
| |
| 53 | for(j=i+1 ; j< 7 ; j++) | |
| 54 | {
| |
| 55 | if(strcmp(text[i],text[j])>0) | |
| 56 | {
| |
| 57 | strcpy(temp , text[i]) ; | |
| 58 | strcpy(text[i] , text[j]) ; | |
| 59 | strcpy(text[j] , temp) ; | |
| 60 | } | |
| 61 | } | |
| 62 | } | |
| 63 | ||
| 64 | for(i=0 ; i< 7 ; i++) | |
| 65 | {
| |
| 66 | puts(text[i]) ; | |
| 67 | } | |
| 68 | ||
| 69 | ||
| 70 | ||
| 71 | ||
| 72 | ||
| 73 | } |