1093 字符串A+B
hash就完事了。
1 #include"iostream" 2 using namespace std; 3 4 //由于字符本身是整数,所以用hash判断字符是否是第一次输出 5 bool hashtable[300]= {false}; 6 int main() { 7 string s1,s2,s; 8 getline(cin,s1); 9 getline(cin,s2); 10 s = s1 + s2;//拼接两个字符串 11 for(int i = 0; i < s.length(); ++i) { 12 if(hashtable[s[i]] == false) { //控制 每个字符只输出一次 13 cout<<s[i]; 14 hashtable[s[i]] = true; 15 } 16 } 17 return 0; 18 }


浙公网安备 33010602011771号