Preprocessor Solution

  • + 0 comments
    #include <cmath>
    #include <cstdio>
    #include <vector>
    #include <iostream>
    #include <algorithm>
    #include <limits.h>
    #define subtract(a, b) a-b
    using namespace std;
    
    
    int main() {
        int n;
        cin >> n;
        vector<int> v(n);
        for(int i = 0; i < n; i++){
            cin >> v[i];
        }
        
        int maxi = INT_MIN;
        int mini = INT_MAX;
        for(int i = 0; i < n; i++){
            if(v[i] > maxi) maxi = v[i];
            if(v[i] < mini) mini = v[i];
        }
        
        cout << "Result = " << subtract(maxi, mini) << endl;
        return 0;
    }