結果
| 問題 |
No.21 平均の差
|
| ユーザー |
youjo_yamioti
|
| 提出日時 | 2018-11-30 14:35:13 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 537 bytes |
| コンパイル時間 | 110 ms |
| コンパイル使用メモリ | 23,168 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-26 23:39:13 |
| 合計ジャッジ時間 | 570 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
26 | scanf("%d %d",&N,&K);
| ~~~~~^~~~~~~~~~~~~~~
main.cpp:28:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf("%d",&array[i]);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include<cstdio>
using namespace std;
int max(int a[]){
int M=0;
int *p = a;
while(*p != 0){
if(*p > M) M = *p;
p++;
}
return M;
}
int min(int a[]){
int m=1000000;
int *p = a;
while(*p != 0){
if(*p < m) m = *p;
p++;
}
return m;
}
int main(){
int N,K;
int array[9];
int i;
int M,m;
scanf("%d %d",&N,&K);
for(i = 0;i < N;i++){
scanf("%d",&array[i]);
}
M = max(array);
m = min(array);
printf("%d\n",M-m);
return 0;
}
youjo_yamioti