Skip to content

Instantly share code, notes, and snippets.

@dannvix
Created July 31, 2015 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannvix/3dfdaf8960e752763f0d to your computer and use it in GitHub Desktop.
Save dannvix/3dfdaf8960e752763f0d to your computer and use it in GitHub Desktop.
Print 1 to 1000 without loop and conditional statements in C++11
#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