I have three loops and i want to combine them to form a matrix where MX is the coordinate in the matrix.How can i form a matrix with 3 different loops?
int main()
{
int k=1,L=0,A=0,i,j,m,e;
int z=1,R=0,C=0; //variable for Q
int B=0,T=0,c=1,q=1,n=0; // variable for diagonal
double P[KMAX];
double Q[KMAX];
double S[KMAX];
double MX[M][M];
double D[M+1][M+1];
double p=0.95;
double a1=20.79,a2=0.005;
int V=3,KM=5;
//cout.setf(ios::fixed);
//cout.precision(6);
for (i=1;i<=KMAX;i++)
{
P[i] = (p*V*i)/(KM+i);
Q[i]= (1-p)*V*i/(KM+i);
//cout <<"P["<<i<<"] = "<< P[i] << "\t"<<"Q["<<i<<"] = " << Q[i] << endl;
}
cout << endl
for (i=KMAX;i>=1;i--)// Calculation for P
{
for (j=1;j<=i;j++)
{
MX [j-1+L][KMAX+k]=P[A+1];
cout <<"MX["<<j-1+L<<"]["<<KMAX+k<<"] = " <<MX[j-1+L][KMAX+k]<<endl;
k++;
}
cout<<endl;
L=k+A;
A++;
}
for (i=KMAX;i>=1;i--)// Calculation for Q
{
for (j=1;j<=i;j++)
{
MX [j+R][KMAX+z]=Q[C+1];
cout <<"MX["<<j+R<<"]["<<KMAX+z<<"] = " <<MX[j+R][KMAX+z]<<endl;
z++;
}
cout<<endl;
R=z+C;
C++;
}
for (i=KMAX+1;i>=1;i--)// calculation for diagonal