結果
| 問題 | No.21 平均の差 |
| コンテスト | |
| ユーザー |
hayakawa4739
|
| 提出日時 | 2018-06-18 15:15:09 |
| 言語 | C90(gcc15) (gcc 15.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 660 bytes |
| 記録 | |
| コンパイル時間 | 179 ms |
| コンパイル使用メモリ | 27,640 KB |
| 最終ジャッジ日時 | 2026-02-24 00:57:33 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c: In function 'sort':
main.c:8:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
8 | for(int i = 0;i < n;i++){
| ^~~
main.c:8:9: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code
main.c:9:17: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
9 | for(int j = 0;j < n-1;j++){
| ^~~
main.c: In function 'input':
main.c:21:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
21 | for(int i = 0;i < n;i++){
| ^~~
ソースコード
#include<stdio.h>
#include<stdlib.h>
void sort(int *num,int n){
int temp;
for(int i = 0;i < n;i++){
for(int j = 0;j < n-1;j++){
if(num[i] <= num[j]){
temp = num[i];
num[i] = num[j];
num[j] = temp;
}
}
}
}
void input(int *num,int n){
for(int i = 0;i < n;i++){
scanf("%d",&num[i]);
}
}
int answer(int *num,int n){
int a,b;
a = num[0];
b = num[n-1];
return b-a;
}
int main(void){
int n,k;
scanf("%d",&n);
scanf("%d",&k);
int *num;
num = (int *)malloc(sizeof(int) * n);
input(num,n);
sort(num,n);
printf("%d\n",answer(num,n));
free(num);
return 0;
}
hayakawa4739