結果

問題 No.275 中央値を求めよ
コンテスト
ユーザー Haijinn
提出日時 2016-12-11 15:30:44
言語 C90
(gcc 12.3.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 465 bytes
記録
コンパイル時間 223 ms
コンパイル使用メモリ 27,232 KB
最終ジャッジ日時 2025-12-04 19:11:37
合計ジャッジ時間 776 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c: In function 'main':
main.c:8:15: error: C++ style comments are not allowed in ISO C90
    8 |         int s;//ソート用
      |               ^
main.c:8:15: note: (this will be reported only once per input file)

ソースコード

diff #
raw source code

#include <stdio.h>

int main(void)
{
	int a;
	int q[1000];
	int i;
	int s;//ソート用
	int sort;//ソート用
	int temp;
	int c;
	
	double w;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d",&q[i]);
	}
	for(sort=0;sort<a-1;sort++){
	for(s=a-1;s>sort;s--){
		if(q[s]>q[s-1]){
			 temp=q[s];
			 q[s]=q[s-1];
			 q[s-1]=temp;
		}
	}
	}
	if(a%2==0){
		
		printf("%f\n",(double)(q[a/2]+q[a/2-1])/2);
		
	}else{
		c=a/2;
		printf("%d\n",q[c]);
		
	}
	
	
	return 0;
}
0