Nash's world

Printing 1 to 1000 without loop or conditionals

by on Jan.03, 2011, under Programing

Print numbers from 1 to 1000 without using any loop or conditional statements.

#include <iostream>
template<int N>
struct NumberGeneration{
  static void out(std::ostream& os)
    os << N << std::endl;
struct NumberGeneration<1>{
  static void out(std::ostream& os)
    os << 1 << std::endl;
int main(){
:, , ,

Leave a Reply


Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!


A few highly recommended websites...


Member of The Internet Defense League