文章
19
粉丝
21
获赞
5
访问
19.0k
# include <bits/stdc++.h>
using namespace std;
int a[20][20];
int n;
int change[15];
void swap_hang(int A,int B){
int t[15];
// t = A
for (int i = 1; i <= n; ++i) t[i] = a[A][i];
// A = B
for (int i = 1; i <= n; ++i) a[A][i] = a[B][i];
// B = t
for (int i = 1; i <= n; ++i) a[B][i] = t[i];
}
int main (void){
cin >> n;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
cin >> a[i][j];
// 按照要求去模拟
for (int i = 1; i <= n; ++i){
// 记录最大数所在的行和他应该交换到的行
int before_change;
int val = -1e9;
int after_change = i;
for (int j = i; j <= n; ++j){
if (a[j][i] > val){
before_change = j;
val = a[j][i];
}
}
// 交换这两行
swap_hang(before_chang...
登录后发布评论
暂无评论,来抢沙发