Hi all ,
This was my solution.
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
static jmp_buf buf;
int main( int argc , char **argv )
{
int i=0;
try {
setjmp(buf);
printf("%d\n",i++);
longjmp(buf,i/(i%300001));
}
catch(...) {}
}
regards
Praseed Pai
P.S :- Template MetaProgramming solution seems to be good. It is a kind of
loop unrolling and it is also called Compile time recursion.
--- On Thu, 3/31/11, Faisal Fiza <[email protected]> wrote:
From: Faisal Fiza <[email protected]>
Subject: Re: [ILUG-Cochin.org] 300000 problem
To: "This List discusses GNU/Linux & GNU, GPL Software "
<[email protected]>
Date: Thursday, March 31, 2011, 11:44 AM
Hehe :)
its good but the 'seq' program may contain loops and conditions.
finally i got the exact link which expected.
http://stackoverflow.com/questions/4568645/printing-1-to-1000-without-loop-or-conditionals
>Althaf's example is good, based on your conditions. You can call an external
>program
>to do this in GNU. The following will print it.
>
>
>int main()
>{
> system("seq 30000");
> }
>
> Regards,
> Jos Collin
>On Thu, Mar 31, 2011 at 07:59:01PM +0530, Faisal Fiza wrote:
> >
> >
> >
> >
> >
> >
> > Recursion still has conditionals to check the exit condition, however goto
> > is
>
> >not exactly a loop, moreover in > the question it doesnt mention program
>should
>
> >terminate once 0 to 3.... is printed, ( word play :-D), either > recursion
>or
>
> >goto will do, recursion will end up in stack over flow, goto will end up in
> >infinite loop. ;-).
>>
>>
>> Conditions:
>> *Program should terminate after printed from 0 to 3lak.
>> *No conditions and loops
>> *If u use assembly , don't use conditional jumps.
>> _______________________________________________
>> Indian Libre User Group Cochin Mailing List
>> http://www.ilug-cochin.org/mailing-list/
>> http://mail.ilug-cochin.org/mailman/listinfo/mailinglist_ilug-cochin.org
>> #[email protected]
_______________________________________________
Indian Libre User Group Cochin Mailing List
http://www.ilug-cochin.org/mailing-list/
http://mail.ilug-cochin.org/mailman/listinfo/mailinglist_ilug-cochin.org
#[email protected]
_______________________________________________
Indian Libre User Group Cochin Mailing List
http://www.ilug-cochin.org/mailing-list/
http://mail.ilug-cochin.org/mailman/listinfo/mailinglist_ilug-cochin.org
#[email protected]
_______________________________________________
Indian Libre User Group Cochin Mailing List
http://www.ilug-cochin.org/mailing-list/
http://mail.ilug-cochin.org/mailman/listinfo/mailinglist_ilug-cochin.org
#[email protected]