Help me out pls...i dont understand why am i getting sigsegv error for many of my problems on spoj.This is one of them:

I mean i know that i am accessing data outside the array but where?

I mean i know that i am accessing data outside the array but where?

You use a debugger to figure it out. Most debuggers will give you the option of setting a break condition; you can use a condition of the array index being out of range. Alternatively, you can go old school and just add debug output at strategic locations and take note of the program's current state when it bombs.

You're not accessing an array wrong, you're causing a stack overflow because Solve() keeps calling itself over and over again when the parameter is zero

@ayush I have said you na that daniweb is the best place for your problems and see they all are helping alot. so keep update from here and ya! i have checked it solve() has problem. use a better algo to avoid that. thanks P.S (your senior :p)

Thanks a lot guys i finally solved it....guess @Tumlee was absolutely right....thanks for going through my code :) and thank you @nitin1 for refering this page to me.

;) yeah! no worries :) it's good to see that your problem is solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.