Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
140497 刘柠锐 矩阵右移动 C++ Compile Error 0 MS 0 KB 1180 2025-12-15 16:17:37

Tests(0/0):


Code:

#include<iostream> using namespace std; int main(){ int m,n; int n1; scanf("%d %d",&m,&n); int m1=m%n; int matrix1[n][n]; int matrix2[n][n]; for(int i=0;i<=n-1;i++){ for(int j=0;j<=n-1;j++){ scanf("%d",&matrix1[i][j]); } } for(int i=0;i<=n-1;i++){ for(int j=0;j<=n-1;j++){ if(j+m1>n-1){ matrix2[i][j+m1-n]=matrix1[i][j]; }else if(j+m1<n-1){ matrix2[i][j+m1]=matrix1[i][j]; } } } for(int i=0;i<=n-1;i++){ for(int j=0;j<=n-1;j++){ printf("%d",matrix2[i][j]); printf(" "); } if(i==n-1)break; printf("\n"); } return 0; } #include<iostream> using namespace std; int main(){ int m,n; int n1; scanf("%d %d",&m,&n); int m1=m%n; int matrix1[n][n]; int matrix2[n][n]; for(int i=0;i<=n-1;i++){ for(int j=0;j<=n-1;j++){ scanf("%d",&matrix1[i][j]); } } for(int i=0;i<=n-1;i++){ for(int j=0;j<=n-1;j++){ if(j+m1>n-1){ matrix2[i][j+m1-n]=matrix1[i][j]; }else if(j+m1<n-1){ matrix2[i][j+m1]=matrix1[i][j]; } } } for(int i=0;i<=n-1;i++){ for(int j=0;j<=n-1;j++){ printf("%d",matrix2[i][j]); printf(" "); } if(i==n-1)break; printf("\n"); } return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:5:5: warning: unused variable 'n1' [-Wunused-variable]
 int n1; 
     ^
Main.cc: In function 'int main()':
Main.cc:36:5: error: redefinition of 'int main()'
 int main(){ 
     ^
Main.cc:3:5: note: 'int main()' previously defined here
 int main(){ 
     ^
Main.cc:38:5: warning: unused variable 'n1' [-Wunused-variable]
 int n1; 
     ^
Main.cc: In function 'int main()':
Main.cc:6:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d %d",&m,&n); 
                     ^
Main.cc:12:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&matrix1[i][j]); 
                            ^
Main.cc: In function 'int main()':
Main.cc:39:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d %d",&m,&n); 
                     ^
Main.cc:45:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&matrix1[i][j]); 
                            ^