View Code of Problem 22

#include <stdio.h>
#include <string.h>
int main()
{
    char a[1000],b[1000];
    int i,j;
    while(scanf("%s%s",&a,&b)!=EOF)
    {
        for(i=0;i<strlen(a);i++)
        {
            for(j=i+1;j<strlen(a);j++)
            {if(a[i]==a[j]) a[j]=' ';}

        }
        for(i=0;i<strlen(b);i++)
        {
            for(j=i+1;j<strlen(b);j++)
            {if(b[i]==b[j]) b[j]=' ';}

        }
        puts(a);
        puts(b);

        for(i=0;i<strlen(a);i++)
            {
                for(j=0;j<strlen(b);j++)
                {
                    if(a[i]==b[j]&&a[i]!=' '&&b[j]!=' ')
                        {
                            printf("%c",b[j]);

                        }
                }
            }
            printf("\n");


    }
}

Double click to view unformatted code.


Back to problem 22