### 8 queens 1d array backtracking infinite solutions?

Pages: 12
hi in this hw problem im supposed to get 92 solutions but i keep getting infinity amount of solutions i have checked my logic and i believe its correct can anyone point me in the right direction thanks

 ``12345678910111213141516171819202122232425262728293031`` `````` #include #include using namespace std; int main () { int counter = 1; int q[8]; int c = 0; int i = 0; q[0] = 0; nc: c++; if (c == 8) goto print; q[c] = -1; nr: q[c]++; if (q[c] == 8) goto backtrack; for (i=0; i < c; i++) { if (q[i] == q[c] && abs(q[c] - q[i]) == c - i) goto nr; } goto nc; backtrack: c--; if (c == -1) return 0; goto nr; print: cout << "Solution number:" << counter << endl; for (int k = 0; k < 8; k++) { cout << q[k]; } cout << endl; counter ++; goto backtrack; }``````
Last edited on
Post the HW problem. This implementation is... the mind boggles.
this is the hw problem?
What does the problem tell you to do?
Complete the 8 queens 1 dimensional array program with backtracking
can anyone help?
your first problem is you're using goto.
lol i know but its required for this hw assignment i have already completed the same one without the goto statement
apparently this problem is too difficult for this forum maybe ill try a different website
Nobody is going to try and disect your un-indented, obfuscated code. A description like the one you've provided is nowhere near enough to make anyone outside of your programming class understand what you're talking about.
 apparently this problem is too difficult for this forum maybe ill try a different website

Your passive-aggressive attempt at reverse psychology is ineffective here.

Yes, perhaps you will have better luck at another website. Though I suspect any other website will tell you the same thing we're telling you.
This does seem tough. I imagine the website you stole that code from wasn't much help either. http://stackoverflow.com/questions/3852077/8-queens-using-one-array
I checked out the Wikipedia article and found a reference to a .pdf that looked pretty good.
http://en.wikipedia.org/wiki/Eight_queens_puzzle
http://www.cl.cam.ac.uk/~mr10/backtrk.pdf
thanks for actually trying to help booradley60 im not sure if its just that people cant read , the code is written in c++ language if u cant understand it then you shouldnt be on this website i just wanted to know if there was something wrong with my alogrithm but forget it
Its fine if you don't like the users on this forum because I'm pretty sure we don't like you either.

Instead of making threats to leave and go to another forum... maybe actually try leaving and going to another forum.

kthxbye

EDIT:

I'm not usually this hostile... but this guy... jeez.
Last edited on
and one more thing i didn't steal the code from any website i made it myself, why would i need to do that, it seems pointless, i wont be able to steal codes when im applying for a job so why would i do it now, you guys are just programmers who weren't good enough to get real jobs so you patrol this sites looking for ways to make others as miserable as you but thats not gonna happen, and im not being passive aggressive it just seems like there are alot of people on this website who dont know anything about c++ but i wont go into detail.
I laughed.
thats because your one of them
Yup. You're right. I know absolutely nothing.

It's pretty sad that one of the top contributors on the board knows so little about C++. You should probably leave and go to a board where people are smarter.
just forget it go "help" someone else
Alright, alright. I had my fun. I'll stop trolling now.
Pages: 12