Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
6777 张育斌 螺旋矩阵 C++ Compile Error 0 MS 0 KB 845 2025-03-15 15:26:23

Tests(0/0):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<bits/stdc++.h> #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int n,a[21][21]; cin>>n; int k; int q=k; int t=1; for(;k=1;k<=(n+1)/2;k++){ for(int j=k;j<=n-k+1&&t<=n*n;j++) a[k][j]=t++; for(int i=q-k+2;i<=n-k+1&&t<=n*n;i++) a[i][n-k+1]=t++; for(int j=n-k;j>=k&&t<=n*n;j--) a[n-k+1][j]=t++; for(int i=n-k;i>=k+1&&t<=n*n;i--) a[i][k]=t++; } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cout<<setw(4)<<a[i][j]; if(j==n) cout<<endl; } } return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:13:12: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     for(;k=1;k<=(n+1)/2;k++){
            ^
Main.cc:13:15: warning: for increment expression has no effect [-Wunused-value]
     for(;k=1;k<=(n+1)/2;k++){
               ^
Main.cc:13:24: error: expected ')' before ';' token
     for(;k=1;k<=(n+1)/2;k++){
                        ^
Main.cc:13:28: error: expected ';' before ')' token
     for(;k=1;k<=(n+1)/2;k++){
                            ^
Main.cc:11:9: warning: unused variable 'q' [-Wunused-variable]
     int q=k;
         ^
Main.cc:12:9: warning: unused variable 't' [-Wunused-variable]
     int t=1;
         ^