# Vector subscript out of range? (Sudoku)

Show 80 post(s) from this thread on one page
Page 2 of 2 First 12
• 03-03-2009
mt1
Quote:

Originally Posted by matsp
Can you describe what it is that you are trying to tackle?

--
Mats

1. The void displayboard function, "You could just put them into your vector before you show the board the first time. " I don't know what you mean by this.

2. I'm still trying to get my program to recognise each cell location so that when the user inputs 1-9 it will be put in to that cell, but before doing that i need enter the constants ike you said earlier, however the way i'm doing it would take forever.
• 03-03-2009
matsp
So, how much do you understand about manipulating vectors in general - how would you put the number 6 in cell number 7 of a vector? Now, if you know that, how would you fill in the constant part of the Sudoku puzzle?

Also, what sort of input have you dealt with so far?

--
Mats
• 03-03-2009
mt1
Quote:

Originally Posted by matsp
So, how much do you understand about manipulating vectors in general - how would you put the number 6 in cell number 7 of a vector? Now, if you know that, how would you fill in the constant part of the Sudoku puzzle?

Also, what sort of input have you dealt with so far?

--
Mats

Never dealt with vectors before, was just an idea I cam across whilst reading my book, thought I could adapt from the Tic Tac Toe program from the book. I tried to adapt from it but it's proving a bit complicated...

Code:

```void instructions() {     cout << "Welcome to the ultimate man-machine showdown: Tic-Tac-Toe.\n";     cout << "--where human brain is pit against silicon processor\n\n";     cout << "Make your move known by entering a number, 0 - 8.  The number\n";     cout << "corresponds to the desired board position, as illustrated:\n\n";         cout << "      0 | 1 | 2\n";     cout << "      ---------\n";     cout << "      3 | 4 | 5\n";     cout << "      ---------\n";     cout << "      6 | 7 | 8\n\n";     cout << "Prepare yourself, human.  The battle is about to begin.\n\n"; }```
about input, the only input i've done is something like this

Code:

```#include <iostream> using namespace std; int main() {                //        Declarations         double celsius, fahrenheit;         //        Input         cout << "Enter temperature in Celsius: ";         cin >> celsius;         cout << endl;         //        Calculation         fahrenheit = (celsius*9)/5 +32;         //        Output         cout << celsius << " Celsius is (approx.) ";         cout << fahrenheit  << "F.";         cout << endl << endl;         return 0; }```
• 03-03-2009
matsp
So, given what you know of the vectors and cin >>.

--
Mats
• 03-03-2009
mt1
Quote:

Originally Posted by matsp
So, how much do you understand about manipulating vectors in general - how would you put the number 6 in cell number 7 of a vector? Now, if you know that, how would you fill in the constant part of the Sudoku puzzle?

Also, what sort of input have you dealt with so far?

--
Mats

cout << " " << board[7];

cin >> board[7];

*shrugs*
• 03-03-2009
matsp
Quote:

Originally Posted by mt1
cout << " " << board[7];

cin >> board[7];

*shrugs*

Right, I think you need to learn a bit more about vectors and input/output (I/O) before you try to write a rather complex program.

I'm sorry, but holding your hand through this is probably a bit too much for me to cope with. Try looking at the tutorials on www.cprogramming.com - I'm pretty sure there is a section on vectors. And another on covers simple input & output.

--
Mats
• 03-03-2009
mt1
Quote:

Originally Posted by matsp
Right, I think you need to learn a bit more about vectors and input/output (I/O) before you try to write a rather complex program.

I'm sorry, but holding your hand through this is probably a bit too much for me to cope with. Try looking at the tutorials on www.cprogramming.com - I'm pretty sure there is a section on vectors. And another on covers simple input & output.

--
Mats

Ok.

I can see file I/O but that's probably not what i'm looking for? Can't see anything about vectors.
• 03-03-2009
Litz
Quote:

Originally Posted by mt1
Ok.

I can see file I/O but that's probably not what i'm looking for? Can't see anything about vectors.

http://www.cprogramming.com/tutorial/stl/vector.html
Show 80 post(s) from this thread on one page
Page 2 of 2 First 12