Preprocessor Solution

  • + 0 comments

    Since I found the exercise a bit unnecessary, I made some shortcuts to avoid using variables in some places. My solution is:

    #define toStr(X) "Result ="
    
    #define io(VEC) cin >> VEC
    
    #define FUNCTION(FUNNAME, OP)                       \
            void FUNNAME(int &m, int num){                   \
                if (num OP m){                                            \
                    m = num;                                               \
                }                                                                 \
            }                                                                     \
    
    
    #define foreach(V, I) for(int I = 0; I < n; I++)
    
    #define INF 999999