#include <iostream>
#include <iomanip>
//notice the addition of iomanip this gives us access to setw
// Make sure we initialize the array to known values NOT >=1 OR <= 25
// Zero is good for this case.
int array[5][5] = {{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}};
// For each row
for (size_t crow = 0; crow < 5; crow++)
{
// For each column
for (size_t ccol = 0; ccol < 5; ccol++)
{
int i = getInput(); // getInput() will get the user input and return value as int.
if (i < 1 || i > 25)
{
// Input range error!
}
else
{
// Look for input.
for (size_t y = 0; y < crow; y++)
{
for (size_t x = 0; x < ccol; x++)
{
if (array[y][x] == i)
{
// Duplicate input error.
}
}
}
}
// If no errors
array[crow][ccol] = i;
}
}
int main(void)
{
//where it all come to gether
long seed=0;
do {
seed = GetNumber();
cout << "You've entered: " << seed << "\n";
if(seed > 0) PrintTable(seed);
cout << "\n\n";
} while(seed != 0); //if 0 is entered we quit
return 0;
}
That should work but it generates an error that i dont know,
4\PRS2\r\main.cpp|8|error: expected unqualified-id before 'for' 4\PRS2\r\main.cpp|8|error: expected constructor, destructor, or type conversion before '<' token|
4\PRS2\r\main.cpp|8|error: expected constructor, destructor, or type conversion before '++' token|
||=== Build finished: 3 errors, 0 warnings ===|