結果

問題 No.113 宝探し
コンテスト
ユーザー しめはじめ
提出日時 2019-07-17 09:37:11
言語 C11(gcc12 gnu拡張)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=gnu11 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 591 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 104 ms
コンパイル使用メモリ 32,388 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-08 16:20:28
合計ジャッジ時間 785 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:26:11: warning: implicit declaration of function ‘sqrt’ [-Wimplicit-function-declaration]
   26 |     dis = sqrt( ( x * x ) + ( y * y ) );
      |           ^~~~
main.c:2:1: note: include ‘<math.h>’ or provide a declaration of ‘sqrt’
    1 | #include <stdio.h>
  +++ |+#include <math.h>
    2 | int main(void){
main.c:26:11: warning: incompatible implicit declaration of built-in function ‘sqrt’ [-Wbuiltin-declaration-mismatch]
   26 |     dis = sqrt( ( x * x ) + ( y * y ) );
      |           ^~~~
main.c:26:11: note: include ‘<math.h>’ or provide a declaration of ‘sqrt’
main.c:6:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf( "%s", move );
      |     ^~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>
int main(void){
    char move[101];
    int x = 0, y = 0;
    float dis = 0;
    scanf( "%s", move );
    for( int i = 0; i < 101; i++ ){
        if( move[i] == '\0' ){
            break;
        }
        switch( move[i] ){
            case 'N':
                y++;
                break;
            case 'S':
                y--;
                break;
            case 'W':
                x--;
                break;
            case 'E':
                x++;
                break;
        }
    }
    dis = sqrt( ( x * x ) + ( y * y ) );
    printf( "%f", dis );
}
0