#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
void convert(char *s2, int freq[])
{
int i,j;
for (i = 0; i <strlen(s2); i++)
{
s2[i] = toupper(s2[i]);
//printf("%s",s2);
j=s2[i] - 'A';
if (freq[j]==0)
{
freq[j] = 1;
}
}
printf("\n");
}
void removechar(char res[], char s1[], int freq[])
{
int i,j = 0,ind;
for (i = 0; i < strlen(s1); i++)
{
s1[i]=toupper(s1[i]);
ind=s1[i]-'A';
if (freq[ind]==0)
{
res[j++] = s1[i];
}
}
res[j] = '\0';
}
int main()
{
char s1[100],s2[100],res[100];
int freq[26]={0};
scanf("%s", s1);
scanf("%s", s2);
convert(s2,freq);
removechar(res,s1,freq);
printf("%s", res);
return 0;
}
ex:
morning
gmi
output:
ORNN
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
void convert(char *s2, int freq[])
{
int i,j;
for (i = 0; i <strlen(s2); i++)
{
s2[i] = toupper(s2[i]);
//printf("%s",s2);
j=s2[i] - 'A';
if (freq[j]==0)
{
freq[j] = 1;
}
}
printf("\n");
}
void removechar(char res[], char s1[], int freq[])
{
int i,j = 0,ind;
for (i = 0; i < strlen(s1); i++)
{
s1[i]=toupper(s1[i]);
ind=s1[i]-'A';
if (freq[ind]==0)
{
res[j++] = s1[i];
}
}
res[j] = '\0';
}
int main()
{
char s1[100],s2[100],res[100];
int freq[26]={0};
scanf("%s", s1);
scanf("%s", s2);
convert(s2,freq);
removechar(res,s1,freq);
printf("%s", res);
return 0;
}
ex:
morning
gmi
output:
ORNN
No comments:
Post a Comment