Run ID:3048

提交时间:2024-03-23 18:42:56

# 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; }