1、图像旋转
题目链接:https://sim.csp.thusaac.com/contest/4/problem/0
100分代码:
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{int n,m;cin >> n >> m;int a[1010][1010];for(int i = 0; i < n; i++){for(int j = 0; j < m; j++){cin >> a[i][j];}}for(int i = m-1; i >= 0; i--){for(int j = 0; j < n; j++){cout << a[j][i] << " ";}cout << endl;}return 0;
}
评测结果:
2、数字排序
题目链接:https://sim.csp.thusaac.com/contest/4/problem/1
100分代码:
#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(int a, int b){return a > b;
}int main(int argc, char *argv[])
{int n;cin >> n;int a[1010],A[1010],b[1010],cnt[1010] = {0};int k = 0;int ans;for(int i = 0; i < n; i++){cin >> a[i];cnt[a[i]]++;if(cnt[a[i]] == 1){A[k] = a[i];k++;}} sort(A , A + k);int t = 0;for(int i = 0; i < 1010; i++){if(cnt[i] > 0 && cnt[i] <= n){b[t] = cnt[i];t++;}}sort(b , b + t, cmp);bool flag[1010];for(int i = 0; i < t; i++){for(int j = 0; j < k; j++){if(cnt[A[j]] == b[i] && flag[A[j]] == false){cout << A[j] << " " << b[i] << endl;flag[A[j]] = true;break;}}}return 0;
}
评测结果: