Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- int compare (const void *a, const void *b){
- char **a1=(char**)a;
- char **b1=(char**)b;
- return strcmp(*a1,*b1);
- }
- int main(){
- int n,i,j,occ,stop;
- char* temp;
- char** a;
- char** b;
- char p[101];
- scanf("%d",&n);
- a=(char**)malloc(n*sizeof(char*));
- for(i=0;i<n;i++)
- a[i]=NULL;
- occ=0;
- for(i=0;i<n;i++){
- scanf("%s",p);
- j=0;
- stop=0;
- while(a[j]!=NULL&&!stop){
- if(strcmp(a[j],p)!=0) j++;
- else stop=1;
- }
- if(!stop){
- a[j]=(char*)malloc(101*sizeof(char));
- strcpy(a[j],p);
- occ++;
- }
- }
- b=(char**)malloc(occ*sizeof(char*));
- for(i=0;i<occ;i++)
- strcpy(b[i],a[i]);
- qsort(b,occ,sizeof(char*),compare);
- for(i=0;i<occ;i++){
- temp=(char*)malloc(101*sizeof(char));
- strcpy(temp,b[i]);
- j=strlen(temp);
- if(j>1){
- if(temp[j-1]=='o'){
- if(temp[j-2]=='t')
- printf("%s",temp);
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment