11.21
include
include
include
using namespace std;
int main() {
vector
int num;
// 读取表A
while (cin >> num && num != -1) {
A.push_back(num);
}
// 读取表B
while (cin >> num && num != -1) {
B.push_back(num);
}
// 合并A和B到C
C.insert(C.end(), A.begin(), A.end());
C.insert(C.end(), B.begin(), B.end());
// 排序C为非递减有序
sort(C.begin(), C.end());
// 删除重复元素
if (!C.empty()) {
vector<int> result;
result.push_back(C[0]);
for (size_t i = 1; i < C.size(); ++i) {
if (C[i] != C[i - 1]) {
result.push_back(C[i]);
}
}
C = result;
}
// 输出结果
for (size_t i = 0; i < C.size(); ++i) {
if (i > 0) {
cout << ",";
}
cout << C[i];
}
cout << endl;
return 0;
}

浙公网安备 33010602011771号