結果

問題 No.275 中央値を求めよ
ユーザー Haijinn
提出日時 2016-12-11 14:00:39
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 469 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 21,376 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-29 03:30:17
合計ジャッジ時間 1,183 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 24 WA * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:14:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         scanf("%d",&a);
      |         ^~~~~~~~~~~~~~
main.c:16:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |                 scanf("%d",&q[i]);
      |                 ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#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;sort++){
	for(s=i;s>sort;s--){
		if(q[s-1]>q[s]){
			 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("%f\n",(double)q[c]);
		
	}
	
	
	return 0;
}
0