結果

問題 No.275 中央値を求めよ
コンテスト
ユーザー ciel
提出日時 2018-06-17 21:36:34
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 197 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 241 ms
コンパイル使用メモリ 30,120 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-08 16:17:16
合計ジャッジ時間 5,118 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other AC * 1 RE * 37
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:21: warning: passing argument 4 of ‘qsort’ from incompatible pointer type [-Wincompatible-pointer-types]
    8 |         qsort(a,N,4,"\x8b\7+\6\xc3");
      |                     ^~~~~~~~~~~~~~~
      |                     |
      |                     char *
In file included from main.c:2:
/usr/include/stdlib.h:971:34: note: expected ‘__compar_fn_t’ {aka ‘int (*)(const void *, const void *)’} but argument is of type ‘char *’
  971 |                    __compar_fn_t __compar) __nonnull ((1, 4));
      |                    ~~~~~~~~~~~~~~^~~~~~~~
main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d",&N);
      |         ^~~~~~~~~~~~~~
main.c:7:22: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         for(;i<N;i++)scanf("%d",a+i);
      |                      ^~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>
#include <stdlib.h>
int main(){
	int N,i=0;
	int a[1000];
	scanf("%d",&N);
	for(;i<N;i++)scanf("%d",a+i);
	qsort(a,N,4,"\x8b\7+\6\xc3");
	printf("%f\n",(a[N/2]+a[~-N/2])/2.0);
}
0