結果

問題 No.401 数字の渦巻き
ユーザー mudbdbmudbdb
提出日時 2016-07-23 00:09:18
言語 C90
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 993 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 22,144 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 03:08:37
合計ジャッジ時間 1,220 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 0 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 0 ms
5,376 KB
testcase_07 AC 0 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 0 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 0 ms
5,376 KB
testcase_14 AC 0 ms
5,376 KB
testcase_15 AC 0 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 0 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 0 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 0 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 0 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 0 ms
5,376 KB
testcase_29 AC 0 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:5:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |   scanf("%d",&N);
      |   ^~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
int M[31][31];
int main() {
  int N;
  scanf("%d",&N);
  int i,j;
  for (i=0; i<=N; i++) {
    for (j=0; j<=N; j++) {
      M[i][j] = 0;
    }
  }
  int c = 1;
  i = 0;
  for (j=0; j<N; j++) {
    M[i][j] = c++;
  }
  j = N-1;
  for (i=1; i<N; i++) {
    M[i][j] = c++;
  }
  i = N-1;
  for (j=N-2; j>=0; j--) {
    M[i][j] = c++;
  }
  j = 0;
  for (i=N-2; i>=1; i--) {
    M[i][j] = c++;
  }
  int stpi[4] = { 0,1,0,-1 };
  int stpj[4] = { 1,0,-1,0 };
  int k = 0;
  int rtry = 0;
  i = 1;
  j = 1;
  while (1) {
    M[i][j] = c++;
    RTRY:
    i += stpi[k];
    j += stpj[k];
    if (M[i][j] != 0) {
      i -= stpi[k];
      j -= stpj[k];
      k++;
      k%=4;
      rtry++;
      if (rtry >= 3) {
        break;
      } else {
        goto RTRY;
      }
    }
    rtry = 0;
  }
  for (i=0; i<N; i++) {
    for (j=0; j<N; j++) {
      printf("%03d",M[i][j]);
      if (j<N-1) {
        printf(" ");
      } else {
        printf("\n");
      }
    }
  }
  return 0;
}
0