結果

問題 No.113 宝探し
ユーザー umashika
提出日時 2016-02-06 17:03:00
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 450 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 23,552 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-26 03:09:30
合計ジャッジ時間 1,051 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |   scanf("%s",c);
      |   ^~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<math.h>
int main(void)
{
  int south_and_north = 0;
  int east_and_west   = 0;
  char c[101];
  int i;
  scanf("%s",c);
  for(i=0;c[i]!='\0';i++){
    switch(c[i]){
    case 'N':south_and_north++;break;
    case 'S':south_and_north--;break;
    case 'E':east_and_west++;break;
    case 'W':east_and_west--;break;
    }
  }
  printf("%f\n",sqrt(south_and_north*south_and_north+east_and_west*east_and_wes\
t));
  return 0;
}
0