結果
問題 |
No.401 数字の渦巻き
|
ユーザー |
![]() |
提出日時 | 2025-03-25 16:43:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,152 bytes |
コンパイル時間 | 475 ms |
コンパイル使用メモリ | 29,184 KB |
実行使用メモリ | 14,776 KB |
最終ジャッジ日時 | 2025-03-25 16:43:16 |
合計ジャッジ時間 | 4,134 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 1 TLE * 1 -- * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 5 | scanf("%d",&val); | ~~~~~^~~~~~~~~~~
ソースコード
#include <stdio.h> int main(){ int val = 0; scanf("%d",&val); // 出力する配列 int ans[val][val]; int reference = 0; int i = 1; while(i != (val * val) + 1){ if(reference % 4 == 0){ // みぎ for(int j = reference / 4;j < val - (reference / 4);j ++){ printf("i:%d j:%d 右\n",reference / 4,j); ans[reference / 4][j] = i; i++; } }else if(reference % 4 == 1){ // した for(int j = (reference / 4) + 1;j < val - (reference / 4);j ++){ printf("i:%d j:%d 下\n",j,(reference / 4) + 1); ans[j][val - (reference / 4) + 1] = i; i++; } }else if(reference % 4 == 2){ // ひだり for(int j = val - (reference / 4);j > reference/ 4;j --){ printf("i:%d j:%d 左\n",reference / 4,j); ans[reference / 4][j] = i; i++; } }else if(reference % 4 == 3){ // うえ for(int j = val - (reference / 4);j > reference/ 4;j --){ printf("i:%d j:%d 上\n",j,reference / 4); ans[j][reference / 4] = i; i++; } } reference++; } for(int i = 0;i < val;i ++){ for(int j = 0;j < val;j ++){ printf("%03d ",ans[i][j]); } printf("\n"); } }