結果

問題 No.275 中央値を求めよ
ユーザー zazaboon
提出日時 2015-09-17 12:15:24
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 472 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 21,888 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-19 06:52:07
合計ジャッジ時間 1,311 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 4 WA * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d",&kazu);
      |         ^~~~~~~~~~~~~~~~~
main.c:14:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                 scanf("%d",&suuchi[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
int sort(const void *a,const void *b)
{
	return *(int*)b-*(int*)a;
}
int main (void)
{
	int kazu,i,suuchi[1000];
	double tyuuouchi;
	scanf("%d",&kazu);
	for(i=0;i<kazu;i++)
	{
		scanf("%d",&suuchi[i]);
	}
	qsort((void*)suuchi,1000,sizeof(suuchi[0]),sort);
	if((kazu % 2) != 0)
	{
		printf("%d",suuchi[(kazu/2)]);
	}
	else
	{
		tyuuouchi=(suuchi[(kazu/2)-1]+suuchi[(kazu/2)]);
		tyuuouchi/=2;
		printf("%f",tyuuouchi);
	}
	return 0;
}
0