给定两个字符串 A 和 B,本题要求你输出 A+B,即两个字符串的并集。要求先输出 A,再输出 B,但重复的字符必须被剔除。
输入格式:
输入在两行中分别给出 A 和 B,均为长度不超过 106的、由可见 ASCII 字符 (即码值为32~126)和空格组成的、由回车标识结束的非空字符串。
输出格式:
在一行中输出题面要求的 A 和 B 的和。
输入样例:
This is a sample test
to show you_How it works
输出样例:
This ampletowyu_Hrk
#include <stdio.h>
#include <string.h>
//标记法
int main(){
char str1[1000001]={0};
char str2[1000001]={0};
char str3[200]={0};
gets(str1);
int str1len=strlen(str1);
gets(str2);
int str2len=strlen(str2);
for(int i=0;i<str1len;i++){
if(str3[str1[i]]==0){
str3[str1[i]]=1;
printf("%c",str1[i]);
}
}
for(int j=0;j<str2len;j++){
if(str3[str2[j]]==0){
str3[str2[j]]=1;
printf("%c",str2[j]);
}
}
return 0;
}