結果

問題 No.21 平均の差
ユーザー HiroakiSoftware
提出日時 2014-11-01 02:55:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 538 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 22,912 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-30 15:47:53
合計ジャッジ時間 951 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%d", &N);
      |         ~~~~~^~~~~~~~~~
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d", &K);
      |         ~~~~~^~~~~~~~~~
main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                 scanf("%d", pNums + i);
      |                 ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

/*
yukicoder No.21
作成者:ヒロソフ
使用言語:C++(new , delete使用の為)
*/
#include <stdio.h>
 
int main(void) {
	int N, K, *pNums ;
	scanf("%d", &N);
	scanf("%d", &K);
	pNums = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", pNums + i);
	}
	int Min = *(pNums), Max = *(pNums)  ,Current;
	for (int i = 1; i < N; i++) {
		Current = *(pNums + i);
		Min = (Current < Min) ? Current : Min;
		Max = (Current > Max) ? Current : Max;
	}
	printf("%d\n", Max - Min);
	delete[]pNums;
	return 0;
}
0