<\/span><\/h2>\n\n\n\nThe first line contains an integer, N<\/em><\/strong>, denoting the size of the array.
The second line contains N<\/em><\/strong> space-separated integers, x<\/em>1<\/em><\/sub>, x<\/em>2<\/em><\/sub>, . . . ,x<\/em>n<\/em><\/sub>,<\/strong> describing the elements in the array.<\/p>\n\n\n\n<\/span>Constraints<\/strong><\/span><\/h2>\n\n\n\n- 1 <= N<\/em> <= 103<\/sup><\/strong><\/li>
- -10 <= x<\/em>i<\/em> <\/sub><= 108<\/sup><\/strong><\/li><\/ul>\n\n\n\n
<\/span>Output Format <\/strong><\/span><\/h2>\n\n\n\nYou are not responsible for printing any output to stdout. Once the necessary preprocessor macros are written, the locked code in your editor will print a line that says Result = Z<\/strong>, where Z<\/em><\/strong> is the difference between the maximum and minimum values in the array.<\/p>\n\n\n\nSample Input<\/strong><\/p>\n\n\n\n5\n32 332 -23 -154 65<\/code><\/pre>\n\n\n\nSample Output<\/strong><\/p>\n\n\n\nResult = 486<\/code><\/pre>\n\n\n\nExplanation<\/strong><\/p>\n\n\n\n332-(-154) = 486<\/em><\/p>\n\n\n\n<\/span>Solution – Preprocessor Solution in C++<\/strong><\/span><\/h2>\n\n\n\n<\/span>C++<\/strong><\/span><\/h3>\n\n\n\n\/* Enter your macros here *\/\n#define toStr(x) #x\n#define io(v) cin >> v\n#define INF 100000000\n#define foreach(v, i) for(int i = 0; i < v.size(); i++)\n#define FUNCTION(name, op) void name(int& a, int b) { if (b op a) a = b; }\n\n#include <iostream>\n#include <vector>\nusing namespace std;\n\n#if !defined toStr || !defined io || !defined FUNCTION || !defined INF\n#error Missing preprocessor definitions\n#endif \n\nFUNCTION(minimum, <)\nFUNCTION(maximum, >)\n\nint main(){\n\tint n; cin >> n;\n\tvector<int> v(n);\n\tforeach(v, i) {\n\t\tio(v)[i];\n\t}\n\tint mn = INF;\n\tint mx = -INF;\n\tforeach(v, i) {\n\t\tminimum(mn, v[i]);\n\t\tmaximum(mx, v[i]);\n\t}\n\tint ans = mx - mn;\n\tcout << toStr(Result =) <<' '<< ans;\n\treturn 0;\n\n}<\/pre>\n\n\n\n