結果

問題 No.113 宝探し
ユーザー Himatsubushin
提出日時 2022-11-04 09:45:24
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 432 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 24,448 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-18 11:00:54
合計ジャッジ時間 1,695 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     scanf("%s", input);
      |     ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <math.h>

int main() {
    char input[101];
    int i, x = 0, y = 0;

    scanf("%s", input);
    for (i = 0; input[i] !='\0'; i++) {
        if (input[i] == 'N')
            y--;
        else if (input[i] == 'S')
            y++;
        else if (input[i] == 'W')
            x--;
        else
            x++;
    }
    printf("%lf\n", sqrt(pow((double)x, 2.0) + pow((double)y, 2.0)));

    return 0;
}
0