Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3047 | 莫业祁 | 矩阵右移动 | C++ | Wrong Answer | 0 MS | 280 KB | 648 | 2024-03-23 18:42:15 |
# include<iostream> using namespace std; int first[101][101],second[101][101]; int n,m,mov; int main(){ cin>>m>>n; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ cin>>first[i][j]; } } mov=m%n; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(j+mov>=n) second[i][j+mov-n]=first[i][j]; else second[i][j+mov]=first[i][j]; } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ cout<<second[i][j]<<" "; if((i+1)%3==0) cout<<"endl"; } } return 0; }
------Input------
2 3 1 2 3 4 5 6 7 8 9
------Answer-----
2 3 1 5 6 4 8 9 7
------Your output-----
2 3 1 5 6 4 8 endl9 endl7 endl