题意:
有两个数组,数组中的元素都是不同的。分别从两个数组中挑一个数字, 然后相加,组合成新的数字,所有新组成数字也不能有相同的。
思路:
组成不同数字的题。
先分别排序,然后依次对应相加。就肯定不会有一样的数字。
#pragma warning(disable:4996)
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
int a[105], b[105];
int main()
{
int T, i, n;
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d", &a[i]);
for (i = 0; i < n; i++)
scanf("%d", &b[i]);
sort(a, a + n);
sort(b, b + n);
for (i = 0; i < n; i++)
cout << a[i] << " ";
cout << endl;
for (i = 0; i < n; i++)
cout << b[i] << " ";
cout << endl;
}
return 0;
}