C Squared Versus Cubed
#include <stdio.h> int sqr(int n) { char p[n][n]; return sizeof p; } int cube(int n) { char p[n][n][n]; return sizeof p; } int main() { printf("%d %d\n", sqr(2), cube(2)); printf("%d %d\n", sqr(3), cube(3)); printf("%d %d\n", sqr(4), cube(4)); printf("%d %d\n", sqr(5), cube(5)); printf("%d %d\n", sqr(6), cube(6)); } ASM generation compiler returned: 0 Execution build compiler returned: 0 Program returned: 0 4 8 9 27 16 64 25 125 36 216
A screenshot of C code defines square and cube functions using variable-length character arrays, then prints their sizes for several values. The joke is that the code produces the mathematically expected squares and cubes, making a dry programming result look surprisingly satisfying. It is sent as a reaction to elegant, correct, or unexpectedly simple code.
- @ithueti / 3178 2020-11-18
- Type
- image
- Size
- 637×800 · 68.7 KiB
- Mood
- сухой юмор
- Language
- en
- Added