結果

問題 No.275 中央値を求めよ
ユーザー HaijinnHaijinn
提出日時 2016-12-11 14:01:38
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 461 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 21,760 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-06 18:32:53
合計ジャッジ時間 1,259 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 0 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 0 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 1 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 0 ms
5,376 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 0 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 0 ms
5,376 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
5,376 KB
testcase_34 WA -
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 WA -
testcase_38 AC 1 ms
5,376 KB
testcase_39 AC 0 ms
5,376 KB
testcase_40 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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("%d\n",q[c]);
		
	}
	
	
	return 0;
}
0