結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-11-08 22:52:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 552 bytes |
| コンパイル時間 | 124 ms |
| コンパイル使用メモリ | 23,552 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-13 14:11:41 |
| 合計ジャッジ時間 | 1,256 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 38 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%d", &a);
| ~~~~~^~~~~~~~~~
main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%lf", &b[k1]);
| ~~~~~^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main(void)
{
int a;
int c;
double tmp;
double b[1000];
int k1, k2;
scanf("%d", &a);
for ( k1 = 1; k1 <= a; k1++ ) {
scanf("%lf", &b[k1]);
}
for ( k1 = 1; k1 < a; k1++ ) {
for ( k2 = 1; k2 < a; k2++ ) {
if ( b[k2] > b[k2+1]) {
tmp = b[k2];
b[k2] = b[k2+1];
b[k2+1] = tmp;
}
}
}
for ( k1 = 1; k1 <= a; k1++ ) {
printf("%.1f ", b[k1]);
}
puts("");
if ( a % 2 == 0 ) {
c = a;
printf("%.1f", (b[c/2] + b[(a/2)+1]) / 2);
} else {
printf("%.1f", b[a/2]);
}
puts("");
return 0;
}