1093 字符串A+B (20 分)

#include <iostream>
using namespace std;
int main() {
    int n;
    string s1, s2;
    getline(cin,s1);
    getline(cin,s2);
    int a[128] = {0};   //  建立一个128的字符的数组
    for (int i = 0; i < s1.length(); i++) {
        if (a[s1[i]] == 0) {  // 如果有的话就输出,然后进行标记,这样遍历两次出现的和没被标记的就会输出
            cout << s1[i];
            a[s1[i]] = 1;
        }
    }
    for (int j = 0; j < s2.length(); j++) {
        if (a[s2[j]] == 0) {  
            cout << s2[j];
            a[s2[j]] = 1;
        }
    }
    return 0;
}
原文地址:https://www.cnblogs.com/Hk456/p/10798162.html