Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3092 | 邓小龙 | 矩阵右移动 | C++ | Accepted | 0 MS | 272 KB | 646 | 2024-04-04 22:43: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((j+1)%3==0) cout<<endl; } } return 0; }