結果

問題 No.476 正しくない平均
ユーザー chaba
提出日時 2017-04-17 13:54:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 338 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 23,296 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 05:22:47
合計ジャッジ時間 878 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
main.cpp:6:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |   scanf("%d", &ave);
      |   ~~~~~^~~~~~~~~~~~
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         scanf("%d", &data);
      |         ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(void) {
  int n, ave;
  scanf("%d", &n);
  scanf("%d", &ave);

  int data;
  double ans;
  double sum = 0;
  int i;
  for (i = 0; i < n; i++) {
	scanf("%d", &data);
	sum += data;
  }
  ans = sum / n;

  printf("%f\n", ans);
  if (ans == ave) {
	printf("YES\n");
  } else {
	printf("NO\n");
  }

  return 0;
}
0