#define minimum(mn, b) mn = min(b)
#define maximum(mx, c) mx = max(c)
#define INF 10000000
#define toStr(a) #a
#define io(v) v.push_back()
#define FUNCTION(a,b) #
#include <iostream>
#include <vector>
using namespace std;
#if !defined toStr || !defined io || !defined FUNCTION || !defined INF
#error Missing preprocessor definitions
#endif
FUNCTION(minimum, <)
FUNCTION(maximum, >)
int main(){
int n; cin >> n;
vector<int> v(n);
foreach(v, i) {
io(v)[i];
}
int mn = INF;
int mx = -INF;
foreach(v, i) {
minimum(mn, v[i]);
maximum(mx, v[i]);
}
int ans = mx - mn;
cout << toStr(Result =) <<' '<< ans;
return 0;
}
This is a sample question from a hackerrank question, so there would be some mistakes in it. I want to know what does the part
FUNCTION(minimum, <)
FUNCTION(maximum, >)
mean ? It doesn't look like a macro as it doesn't start with #define. The discussion forums too didn't have a good explanation about this part, just that it relates to the macro defined as #define minimum(mn, b) mn = min(b) and #define maximum(mx, c) mx = max(c). ' I want to know what's it called and some advice on good resource to read about it.
The title is poorly written as I have no clue what to refer to that doubtful part of code as.
Aucun commentaire:
Enregistrer un commentaire