I am trying to run through the matrix so i can access with an recursive way like this: array[0,columns/2] and array[0,columns/2 +1] to array[1,columns/4], array[0,columns/4+1], array[1,3/4*columns] and array[1,3/4*columns+1] and so on. n and m are given on the run and n are the lines and columns=pow(2,n+2). My program runs but i can't get results because it crashes or sometimes it prints hex. Here is my code(please ignore my comments because threre in greek):
main()
{
cout << "This is the game that is called: Remove the prelast nucleotide of the second sequence and win!";//Åêôýðùóç åéóáãùãéêïý ìçíýìáôïò ðñïò ôïí ÷ñÞóôç.
cout << endl;
int n;//Ïñéóìüò ìåãßóôïõ ðñþôçò áëëçëïõ÷ßáò.
//int max_step;//Ïñéóìüò ïñßïõ ìÝãéóôïõ âÞìáôïò.
int step = 2;//Ïñéóìüò êáé áñ÷éêïðïßçóç âÞìáôïò.
bool checking1;
do //Âñü÷ïò åðáíÜëçøçò üðïõ ï ÷ñÞóôçò ïñßæåé ôï ìÝãéóôï ôçò ðñþôçò áëëçëïõ÷ßáò ìå Ýëåã÷ï åãêõñüôçôáò.
{
cout << "Please select the maximum of the first sequence (n): ";
checking1 = true;
if (!(cin >> n)||(n > 8)||(n <= 0))
{
cout << endl;
cout << "The maximum of the sequence (n) must be an integer (not char) between 8 and 1!";
cin.clear();
cin.ignore(100000, '\n');
checking1 = false;
cout << endl;
}
}while (checking1 == false);
int m; //Ïñéóìüò ìåãßóôïõ äåýôåñçò áëëçëïõ÷ßáò.
bool checking2;
do //Âñü÷ïò åðáíÜëçøçò üðïõ ï ÷ñÞóôçò ïñßæåé ôï ìÝãéóôï ôçò äåýôåñçò áëëçëïõ÷ßáò ìå Ýëåã÷ï åãêõñüôçôáò.
{
cout << "Please select the maximum of the second sequence (m): ";
checking2 = true;
if (!(cin >> m)||(m >= n)||(m <= 0))
{
cout << endl;
cout << "The maximum of the sequence (m) must be an integer (not char) between "<< n-1<< " and 1!";
cin.clear();
cin.ignore(100000, '\n');
checking2 = false;
cout << endl;
}
access to the array with comma is syntaxly correct, but semanticaly wrong!!!
cout << array[i - 1, (int)columns / j];
this code means:
1. do "i-1" - irrelevant code!
2. do "(int) columns/j
use 2. term to access to array : array[(int) columns/j] and this delivers the address to the columns of the (int) columns/j 'th row of your array!
use two breakets array [] [] for the two dimensional array!
cout << array [i-1] [(int)columns/j];
I registered that this semanticaly error is not found with cppcheck!
I tried that but i am afraid i 've done something wrong. It compiles, but i get this error on runtime: terminate called after throwing an instance of 'int'
main()
{
cout << "This is the game that is called: Remove the prelast nucleotide of the second sequence and win!";
cout << endl;
int n;
//int max_step;
int step = 2;
bool checking1;
do
{
cout << "Please select the maximum of the first sequence (n): ";
checking1 = true;
if (!(cin >> n)||(n > 8)||(n <= 0))
{
cout << endl;
cout << "The maximum of the sequence (n) must be an integer (not char) between 8 and 1!";
cin.clear();
cin.ignore(100000, '\n');
checking1 = false;
cout << endl;
}
}while (checking1 == false);
int m;
bool checking2;
do
{
cout << "Please select the maximum of the second sequence (m): ";
checking2 = true;
if (!(cin >> m)||(m >= n)||(m <= 0))
{
cout << endl;
cout << "The maximum of the sequence (m) must be an integer (not char) between "<< n-1<< " and 1!";
cin.clear();
cin.ignore(100000, '\n');
checking2 = false;
cout << endl;
}
This is the game that is called: Remove the prelast nucleotide of the second sequence and win!
Please select the maximum of the first sequence (n): 3
Please select the maximum of the second sequence (m): 2
columns= 64