Untitled

Anonymous
plain_text
11/25/2023 2:43 PM
428 B
12
Indexable
#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;
}
Editor is loading...
Leave a Comment