Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int main(void)
- {
- char temp[1000] ; int i ;
- char text[7][80]={ "Ahen" , "innn" , "the" , "course" , "ooof" , "human" , "events" } ;
- char TEXT[7][80] ;
- for(i=0 ; i<7 ; i++)
- {
- strcpy(TEXT[i],text[i]) ;
- }
- for(i=0 ; i<7 ; i++)
- {
- strlwr(text[i]) ;
- }
- char a[1000] ;
- gets(a) ; int c=0;
- strlwr(a) ;
- for(i=0 ; i<7 ; i++)
- {
- if(strcmp(a,text[i])==0)
- {
- {printf("found\nindex:%d\n",i) ;c++;}
- }
- }
- if(c==0)
- {
- printf("not found\n") ;
- }
- int j ;
- printf("\nSorted:\n\n") ;
- for(i=0 ; i<7 ; i++)
- {
- for(j=i+1 ; j< 7 ; j++)
- {
- if(strcmp(text[i],text[j])>0)
- {
- strcpy(temp , text[i]) ;
- strcpy(text[i] , text[j]) ;
- strcpy(text[j] , temp) ;
- }
- }
- }
- for(i=0 ; i< 7 ; i++)
- {
- puts(text[i]) ;
- }
- }
Add Comment
Please, Sign In to add comment