竞赛
考级
只要到m行输出n行的数据,n行输出m行的数据。
Z
法兰西玫瑰
zsy
啥也别说了,多定义几个变量就好了,上代码
😋🙀😡😤
#include <bits/stdc++.h> using namespace std; int a[105][105]; int main(){ int n,m; for(int i=0;i<5;i++){ for(int j=0;j<5;j++){ cin>>a[i][j]; } } cin>>n>>m; for(int j=0;j<5;j++){ swap(a[n-1][j],a[m-1][j]); } for(int i=0;i<5;i++){ for(int j=0;j<5;j++){ cout<<a[i][j]<<" "; } cout<<endl; } return 0; }
张高纶
Alex
Tian
majmDZB
LS_YZY
直接用swap就行了
暴力出奇迹,结果TLE
#include<bits/stdc++.h> using namespace std; int n[114][514]; int main(){ int a,b; for(int i=1;i<=5;i++){ for(int j=1;j<=5;j++){ cin>>n[i][j]; } } cin>>a>>b; for(int i=1;i<=5;i++){ for(int j=1;j<=5;j++){ swap(n[a][j],n[b][j]); } } for(int i=1;i<=5;i++){ for(int j=1;j<=5;j++){ cout<<n[i][j]<<" "; } cout<<endl; } return 0; }
准
提交答案之后,这里将显示提交结果~