結果
| 問題 |
No.21 平均の差
|
| コンテスト | |
| ユーザー |
youjo_yamioti
|
| 提出日時 | 2018-11-30 14:34:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 535 bytes |
| コンパイル時間 | 283 ms |
| コンパイル使用メモリ | 23,424 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-26 23:39:09 |
| 合計ジャッジ時間 | 2,115 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:13: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘int’ [-Wformat=]
26 | scanf("%d %d",N,K);
| ~^ ~
| | |
| int* int
main.cpp:26:16: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘int’ [-Wformat=]
26 | scanf("%d %d",N,K);
| ~^ ~
| | |
| int* int
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]);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:26:10: warning: ‘N’ is used uninitialized [-Wuninitialized]
26 | scanf("%d %d",N,K);
| ~~~~~^~~~~~~~~~~~~
main.cpp:26:10: warning: ‘K’ is used uninitialized [-Wuninitialized]
ソースコード
#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