Created
July 31, 2015 14:44
-
-
Save dannvix/3dfdaf8960e752763f0d to your computer and use it in GitHub Desktop.
Print 1 to 1000 without loop and conditional statements in C++11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
int main(int n) { | |
static int(*f[])(int) = {main, [](int)->int{exit(0);}}; | |
std::cout << n << std::endl; | |
return f[n/1000](n+1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment