結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
![]() |
提出日時 | 2015-09-17 12:17:57 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 476 bytes |
コンパイル時間 | 166 ms |
コンパイル使用メモリ | 22,016 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 06:52:08 |
合計ジャッジ時間 | 1,188 ms |
ジャッジサーバーID (参考情報) |
judge2 / 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]); | ^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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\n",suuchi[(kazu/2)]); } else { tyuuouchi=(suuchi[(kazu/2)-1]+suuchi[(kazu/2)]); tyuuouchi/=2; printf("%f\n",tyuuouchi); } return 0; }