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