結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
![]() |
提出日時 | 2016-12-11 15:30:44 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 465 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 21,632 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-25 00:09:13 |
合計ジャッジ時間 | 1,220 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
コンパイルメッセージ
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]); | ^~~~~~~~~~~~~~~~~
ソースコード
#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; }