View Code of Problem 22

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

int main()
{
	 char a[100],b[100],c[100];
	 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++;j=strlen(b);}
		
				 for(int m=0;m<k;m++){
					 for(int n=m;n<k-1;n++)if(c[n]>c[n+1]){
						char w=c[n];
						c[n]=c[n+1];
						c[n+1]=w;
					 
					 }
					
				 }
				for(int e=0;e<k;e++)printf("%c",c[e]);
				printf("\n");
	
	 }
}	

Double click to view unformatted code.


Back to problem 22