A. 有序序列合并

把两个数组的数全部输入到一个数组,然后对这个数组进行全排列。

#include<algorithm>
using namespace std;
int main() {
	int m, n;
	cin >> m >> n;
	int a[2010], b[1010];
	for (int i = 0; i < m; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[m + i]);
	}
	sort(a, a + m + n);
	for (int i = 0; i < m + n; i++) {
		cout << a[i]<<" ";
	}
	return 0;
}

B.Dragon:

将数组从大到小排列,然后把数组转化为数字

#include<cstdio>
#include<algorithm>
using namespace std;
bool cmp(int a, int b) {
    return a > b;
}
int main() {
    int a[5];
    while (cin >> a[0]) {
        for (int i = 1; i < 4; i++) {
            cin >> a[i]; 
        }
        sort(a, a + 4, cmp);
     
    int sum = 0;
    for (int i = 0; i < 4; i++) {
        sum = sum * 10 + a[i];
    }
    cout << sum<<endl;
    }
    return 0**;**
}

C.花样方阵:

用一个二维数组存放,然后计算每一组的最大值。

#include<algorithm>
using namespace std;
int main() {
	int T;
	cin >> T;
	while (T--) {
		int n;
		int a[110][5];
		cin >> n;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 4; j++) {
				cin >> a[i][j];
			}
		}
		int b[110];
		int max = 0;
		for (int i = 0; i < n; i++) {
			b[i] = abs(a[i][2] - a[i][0]) + abs(a[i][3] - a[i][1]);	
			if (max < b[i])max = b[i];
		}
		cout << max<<endl;
	}
1. 	return 0;
}

D.不重复数字:

由于set有自动去重的功能,所以我选择用了unordered_set

#include<iostream>
#include<unordered_set>
#include<cstdio>
using namespace std;
unordered_set<int>st;
int main() {
	int T, n , x;
	cin >> T;
	while (T--) {
		st.clear();
		cin >> n;
		for (int i = 0; i < n; i++) {
			scanf("%d", &x);
			if (st.find(x) == st.end()) {
				cout << x <<" ";
				st.insert(x);
			}
		}
		cout << endl;
	}
	return 0;
}

E.小H和迷宫

将数组排序,求最少剩余多少,然后用总的减去剩余的。

#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n;
	double a[4];
	cin>>n>>a[1]>>a[2]>>a[3];
	long long nn=n;
	sort(a+1,a+4);
 for (int i = 3; i > 0; i--) {
     nn = nn - nn*a[i]/100;
 }
	printf("%lld\n",n-nn);
    return 0;
}