結果

問題 No.21 平均の差
コンテスト
ユーザー A63295
提出日時 2015-12-17 23:26:13
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
RE  
実行時間 -
コード長 349 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 117 ms
コンパイル使用メモリ 28,868 KB
最終ジャッジ日時 2026-02-23 20:08:54
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:10: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘int’ [-Wformat=]
    7 | scanf ("%d",n[i]);
      |         ~^  ~~~~
      |          |   |
      |          |   int
      |          int *
main.c:5:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 | scanf ("%d%d", &N, &K);
      | ^~~~~~~~~~~~~~~~~~~~~~
main.c:7:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 | scanf ("%d",n[i]);
      | ^~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>
int main(void){
int i, j, tmp, a, N, K;
int n[] = {0};
scanf ("%d%d", &N, &K);
for ( i = 0; i < N; i++){
scanf ("%d",n[i]);  
}
for ( i = 0; i < N - 1; i++){
   for ( j = i +1; j < N; j++){
      if ( n[i] > n[j])
      tmp = n[i];
      n[i] = n[j];
      n[j] = tmp;
   }
}
a = n[N - 1] - n[0];
printf ( "%d", a);
   return 0;
}
0