How to run through a two dimensional matrix by using pow(2,n)?

I am trying to run through an array and its dimensions are being created as the program runs. I want to run specific elements of the array as array[0,columns/2], then array[1,columns/4] and array[1,columns*3/4], then array[2,columns*1/8],array[2,columns*3/8], etc Forgive for my poor english.

My code so far is this:

#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <ctime>
#include <cmath>
using namespace std;

main()
{
cout << "This is the game that is called: Remove the prelast nucleotide of the second sequence and win!";
cout << endl;
int n;.

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;
}



}while (checking2 == false);




double columns;

//columns = (pow((double)2,(double)n)+0.5*pow((double)2,(double)n));
columns=pow(2,(double)n+1);
cout << "columns= "<<columns;

cout << endl;
cout << endl;
cin.ignore(256, '\n');
cout << "Press ENTER to continue..." << endl;
cin.get();


try
{

int** array;
array = new int*[n];
for (int i = 0;i<n;i++)
array[i] = new int[(int)columns];

}
catch (exception& ex)
{

cout << "Exception: "<<ex.what();
}

int array[n][(int)columns];

try
{

for (int i=0; i<n; i++)
{
for (int j=0; j<columns; j++)
array[i][(int)columns]=-1;
}

}
catch (exception& ex)
{

cout << "Exception: "<<ex.what();
}






cout << endl;

array[0][(int)columns/2]=n;
array[0][(int)columns/2+1]=m;

for (int i=1; i<=n; i++)
for (int j=1; j<=pow(2,i+1); j=pow(2,i) )
{

//double h1 = pow(2,i+1);
//double h2 = pow(2,i);

//int h3 = 2*j+1;




array[i,(int)1/(j+1)]=array[i-1,(int)1/j]-1;




}








cout << endl;
cout << endl;
cin.ignore(256, '\n');
cout << "Press ENTER to continue..." << endl;
cin.get();


}

the error i get is this:
128 48 [Error] incompatible types in assignment of 'int*' to 'int [(((sizetype)(((ssizetype)(int)columns) + -1)) + 1)]'
closed account (48bpfSEw)
use malloc (and delete) instead of static definition of an array

 
int array[n][(int)columns];





http://stackoverflow.com/questions/1970698/using-malloc-for-allocation-of-multi-dimensional-arrays-with-different-row-lengt
closed account (48bpfSEw)
 
 array[i][(int)(1 / (j + 1))] = array[i - 1][(int)(1 / j)] - 1;
Thanks! It was solved!
Topic archived. No new replies allowed.