結果

問題 No.1806 Rotating Golem
ユーザー Maeda
提出日時 2025-03-11 16:24:37
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 25,344 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-11 16:24:39
合計ジャッジ時間 1,312 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:6:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%c\n",&a);
      |     ^~~~~~~~~~~~~~~~
main.c:8:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     scanf("%c",&b);
      |     ^~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

void main(void){
    char nesw[10] = "NESW";
    char a = 'a';
    scanf("%c\n",&a);
    char b = 'b';
    scanf("%c",&b);
    int count = 0;
    for(int i = 0 ; i < 4 ; i++){
        if(nesw[i] == a){
            count = i;
        }
    }
    int rotation = 0;
    while(a != b){
        count++;
        if(count == 4){
            count = 0;
        }
        rotation++;
        a = nesw[count];
        
    }
    
    
    printf("%d",rotation);
}
0