結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2015-09-17 15:09:47 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 466 bytes |
コンパイル時間 | 234 ms |
コンパイル使用メモリ | 22,144 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-24 23:17:26 |
合計ジャッジ時間 | 1,470 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d", &n); | ^~~~~~~~~~~~~~~ main.c:8:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d", &a[i]); | ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>int main(void) {int a[1001], tmp;int i, j, n;scanf("%d", &n);for(i = 0;i < n;i++){scanf("%d", &a[i]);}for(i = 0;i < n - 1;i++){for(j = i + 1;j < n;j++){if(a[j] < a[i]){tmp = a[j];a[j] = a[i];a[i] = tmp;}}}/*for(i = 0;i < n;i++){printf("%d ", a[i]);}*/if(n % 2 == 1){printf("%.1f", (float)a[n / 2]);}else{printf("%.1f", (a[n / 2 - 1] + a[n / 2]) / 2.0);}return 0;}