結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
toto
|
| 提出日時 | 2025-03-25 16:21:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 916 bytes |
| コンパイル時間 | 1,715 ms |
| コンパイル使用メモリ | 28,416 KB |
| 実行使用メモリ | 8,732 KB |
| 最終ジャッジ日時 | 2025-03-25 16:21:55 |
| 合計ジャッジ時間 | 4,062 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 3 TLE * 1 -- * 25 |
コンパイルメッセージ
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 ++){
ans[reference / 4][j] = i;
i++;
}
}else if(reference % 4 == 1){
// した
for(int j = reference / 4;j < val - (reference / 4);j ++){
ans[j][reference / 4] = i;
i++;
}
}else if(reference % 4 == 2){
// ひだり
for(int j = val - (reference / 4);j > reference/ 4;j --){
ans[reference / 4][j] = i;
i++;
}
}else if(reference % 4 == 3){
// うえ
for(int j = val - (reference / 4);j > reference/ 4;j --){
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");
}
}
toto