View Code of Problem 22

#include<stdio.h>
#include<string.h>
#include<math.h>

int main()
{
	 char a[1000],b[1000],c[1000];
	 while(gets(a)){
		gets(b);
		int k=0;
		for(int i=0;i<strlen(a);i++){
			for(int j=0;j<strlen(b);j++){
				if(a[i]==b[j]){c[k]=a[i];k++;b[j] = '#';break;}}}
		
				 for(int m=0;m<k;m++){
					 for(int n=m+1;n<k;n++)if(c[m]>c[n]){
						char w=c[m];
						c[m]=c[n];
						c[n]=w;
					 
					 }
					
				 }
				c[k]='\0';
				puts(c);
			
	
	 }
	 return 0;
}	

Double click to view unformatted code.


Back to problem 22