結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
zazaboon
|
| 提出日時 | 2015-09-17 12:20:34 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 480 bytes |
| コンパイル時間 | 153 ms |
| コンパイル使用メモリ | 21,760 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-19 06:52:14 |
| 合計ジャッジ時間 | 1,317 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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.0\n",suuchi[(kazu/2)]);
}
else
{
tyuuouchi=(suuchi[(kazu/2)-1]+suuchi[(kazu/2)]);
tyuuouchi/=2;
printf("%.1f\n",tyuuouchi);
}
return 0;
}
zazaboon