結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
![]() |
提出日時 | 2016-11-20 10:56:06 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 410 bytes |
コンパイル時間 | 161 ms |
コンパイル使用メモリ | 21,632 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-27 06:50:53 |
合計ジャッジ時間 | 1,334 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 6 WA * 32 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d", &n); | ^~~~~~~~~~~~~~~ main.c:9:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d", &a[i]); | ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(void) { int n, i,j, a[1000], w, k, cnt=0; double ans; scanf("%d", &n); for(i=0; i<n; i++){ scanf("%d", &a[i]); cnt++; } for(i=0; i<n; i++){ for(j=n-1; j>i; j--){ if(a[i]>a[j]){ w = a[i]; a[i] = a[j]; a[j] = w; } } } if(cnt%2==0){ k = i/2; ans = a[k]/a[k+1]; }else{ k = i/2; k++; ans = a[k]; } printf("%lf", ans); return 0; }