View Code of Problem 22

#include<stdio.h> 
#include<string.h>
int main(){ 
    int i,j,la,lb,lc,k;
	char a[1000],b[1000],c[1000],t;
	while(gets(a)!=NULL){
		gets(b);
		la=strlen(a);
		lb=strlen(b);
		k=0;
		for(i=0;i<la;i++){
			for(j=0;j<lb;j++){
				if(a[i]==b[j]){
					c[k++]=a[i];
					b[j]='*';
					break;
				}
			}
		}
		
		for(i=0;i<k;i++){
			for(j=i+1;j<k;j++){
				if(c[i]>c[j]){
					t=c[i];
				    c[i]=c[j];
				    c[j]=t;
				}
			}
		}
		c[k]='\0';
		puts(c);
	}	   
	

	return 0;
} 

Double click to view unformatted code.


Back to problem 22