結果
| 問題 |
No.21 平均の差
|
| ユーザー |
hayakawa4739
|
| 提出日時 | 2018-06-18 15:15:09 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 660 bytes |
| コンパイル時間 | 410 ms |
| コンパイル使用メモリ | 21,888 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-30 16:54:53 |
| 合計ジャッジ時間 | 967 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
main.c: In function ‘input’:
main.c:22:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | scanf("%d",&num[i]);
| ^~~~~~~~~~~~~~~~~~~
main.c: In function ‘main’:
main.c:39:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d",&n);
| ^~~~~~~~~~~~~~
main.c:40:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
40 | scanf("%d",&k);
| ^~~~~~~~~~~~~~
ソースコード
#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