Untitled

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
285 B
0
Indexable
Never
#include <iostream>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int n1 = 0;
	int max = -1;
	int min = 2147483647;
	for (int i = 0; i < n; i++) {
		cin >> n1;
		if (n1 > max) {
			max = n1;
		}
		if (n1 < min) {
			min = n1;
		}
	}
	cout << max - min;
}
Leave a Comment