C++ a good code
3 posters
Page 1 of 1
C++ a good code
i came across a gud code to print n natural numbers without the use of loop
- Code:
#include<iostream>
#include<cstdlib>
using namespace std;
int (*func[2])(int, char **);
int my_exit(int n, char **);
int main(int n=1, char** x = NULL)
{
static int i = 0;
cout<<endl<<n;
func[0]=&my_exit;
func[1]=&main;
i = ++n <= 10;
(func[i])(n, NULL);
}
int my_exit(int n = 1, char **y = NULL) {
exit(0);
}
Last edited by Beagle on Fri Mar 06, 2009 7:23 pm; edited 1 time in total (Reason for editing : The code was not correct.)
shivang- Posts : 42
Join date : 2009-01-30
Age : 35
Re: C++ a good code
its recursively calling main... i haven't run it myself... but i think it should work fine
ramthegreatcv- Posts : 55
Join date : 2009-01-30
Age : 35
Similar topics
» longest increasing subsequence
» tree mirror code
» common ancestor in bst code
» Code to check if a tree is a BST
» Singleton class - only a single object
» tree mirror code
» common ancestor in bst code
» Code to check if a tree is a BST
» Singleton class - only a single object
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|