View Code of Problem 22

#include<stdio.h>
#include<string.h>
int main(){
	char a[1000];
	char b[1000];
	char same[1000];
	char final[1000];
	int count=0;
	int t;
	while(gets(a)!=NULL){
	gets(b);
	for(int i=0;i<strlen(a);i++){
		for(int j=0;j<strlen(b);j++){
			if(a[i]==b[j]){
				same[count]=a[i];
				b[j]='0';
				count++;
				break;
			}
		}
	}
    for(int k=0;k<count;k++){
    	for(int z=k;z<count;z++){
	    	if(same[k]>same[z]){
	    		t=same[k];
	    		same[k]=same[z];
	    		same[z]=t;
	    	}
	    }
    }
   for(int k=0;k<count;k++)
    printf("%c",same[k]);
    count=0;
	printf("\n");
	}
	

}

Double click to view unformatted code.


Back to problem 22