View Code of Problem 22

#include <stdio.h>
#include <stdlib.h>
#include<ctype.h>
#include<string.h>
#include<math.h>
int main()
{
	char a[1000], b[1000],c[1000],ch,temp;
	int i, j,k, min,flag;
	while (scanf("%s%s", a, b)!=EOF)
	{
		k = 0;
		
		for (i = 0; i < strlen(a); i++)
		{
			
			
			for (j = 0; j < strlen(b); j++)
			{
				
				if (a[i] == b[j])
				{
					c[k++] = a[i];
					b[j] = '*';
					break;
				}
			}
			
		}
		c[k] = '\0';
		char temp;
		for (i = 0; i < k; i++)
		{
			for (j = i + 1; j < k; j++)
			{
				if (c[i] > c[j])
				{
					temp = c[j];
					c[j] = c[i];
					c[i] = temp;
				}
			}
			printf("%c",c[i]);
		}

		printf("\n");
	}


	return 0;
}

Double click to view unformatted code.


Back to problem 22