Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define diff(i, j) ( (*M[i]) - (*M[j]) > 0 ? (*M[i]) - (*M[j]) : (*M[j]) - (*M[i]) )
- #define f(name) ( name(0, name(1, name(2, 3))) )
- #define min(i, j) ( (*M[i]) < (*M[j]) ? i : j )
- #define max(i, j) ( (*M[i]) > (*M[j]) ? i : j )
- #define SET_M(x) unsigned long **x = (unsigned long **) malloc(4 * sizeof(unsigned long *))
- #define MAKE { scanf("%u", &n); SET INPUT qsort(M[t], n, sizeof(unsigned long), compare); }
- #define SET { M[i] = (unsigned long *) malloc(n * sizeof(unsigned long)); E[i] = &M[i][n]; }
- #define INPUT for (t = 0; t < n; ++t) scanf("%lu", &M[i][t]);
- #define UPDATE if (curr < res) res = curr; ++M[0]; ++M[1]; ++M[2]; ++M[3];
- #define END_WORK printf("%lu %lu %lu %lu", *M[0], *M[1], *M[2], *M[3]); return 0; }
- int compare(const void *a, const void *b) { return *(unsigned long *) a - *(unsigned long *) b;
- int main() { unsigned int n, t, i = 0; SET_M(M); SET_M(E); MAKE MAKE MAKE MAKE
- unsigned long curr, res = diff(f(max), f(min));
- while (res) { curr = diff(f(min), f(max)); UPDATE if (M[f(min)] == E[f(min)]) END_WORK } END_WORK }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement