Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
320 B
0
Indexable
Never
#include <iostream>

using namespace std;

int main() {
    int n, a;
    cin >> n;
    int temp = n;
    cin >> a;
    int max = a;
    int min = a;
    temp -= 1;
    
    while (temp > 0) {
        cin >> a;
        if (a > max) max = a;
        if (a < min) min = a;
        temp -= 1;
    }
    cout << max - min;
}
Leave a Comment