View Code of Problem 22

#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
	char a[100];
	char b[100];
	char c[100];
	while(gets(a)){
		gets(b);
		int i,j;
		int k=0;
		char temp;
		int n=strlen(a);
		int m=strlen(b);
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				if(a[i]==b[j]){
					c[k]=b[j];
					b[j]='1';
					k++;
					break;
				}
			}
		}
		c[k]='\0';
		for(i=0;i<strlen(c);i++){
			for(j=i;j<strlen(c);j++){
				if(c[i]>c[j]){
					temp=c[i];
					c[i]=c[j];
					c[j]=temp;
				}
			}
		}
		puts(c);
		printf("\n");
		
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 22