Preprocessor Solution

Sort by

recency

|

184 Discussions

|

  • + 0 comments

    This has to be the worst defined problem that I had ever solved. Literally.

  • + 0 comments

    include #include

    include #define subtract(a,b) a-b

    int main() { int t;std::cin>>t; std::vector vec; for(int i=0, a;i>a, vec.push_back(a); auto maxi=std::max_element(vec.begin(),vec.end()), mini=std::min_element(vec.begin(),vec.end()); std::cout<<"Result = "<

  • + 0 comments
    #define toStr(x) #x
    #define io(v) cin >> v
    #define INF 100000000
    #define foreach(v, i) for(int i = 0; i < v.size(); i++)
    #define FUNCTION(name, op) void name(int& a, int b) { if (b op a) a = b; }
    
  • + 0 comments

    Macros:

    #define toStr(x) #x
    #define io(v) cin >> v 
    #define FUNCTION(name, op) inline void name(int &x, int y) {if(y op x) x = y;}
    #define INF 10000000
    #define foreach(v, i) for(int i = 0; i < v.size(); i++)
    
  • + 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;
    }