posted 12 years ago
This is my assignment
I coded a solution but, it seems to be way off the output
You can see for yourself
#include<iostream>
#include<stdlib.h>
#include<math.h>
using namespace std;
int main()
{
int n,x,c,u[100],m[100],e[100][5],j;
cout<<"Enter the number of variables";
cin>>n;
cout<<"Enter the Lower, and Upper Limits of the variables";
for(int y=0; y<n; y++)
{
cin>>m[y];
cin>>u[y];
}
c=(n*4)-4;
for(double k=0; k<n; k++)
{
int k1 = k;
int l=0,l1=1,l2=3,l3=4,l4=5;
double l00=0,l01=0,l02=0,l03=0,l04=0;
for(int i=1; i<=pow(5,n-(k+1)); i++)
{
l00 = l+pow(5,k);
while(l<l00){
e[k1][l] = m[k1];
l++;
}
l1 = l;
l01 = l1 + pow(5,k);
while(l1<l01)
{
e[k1][l1] = m[k1]+1;
l1++;
}
l2 = l1;
l02 = l2 + pow(5,k);
while(l2<l02)
{
e[k1][l2] = u[k1]-1;
l2++;
}
l3 = l2;
l03 = l3 + pow(5,k);
while(l3<l03)
{
e[k1][l3] = u[k1];
l3++;
}
l4=l3;
l04 = l4 + pow(5,k);
while(l4<l04)
{
e[k1][l4] = (u[k1]+m[k1])/2;
l4++;
}
l=l4+1;
}
}
double n1 = n;
for(int j=0; j<pow(5,n1); j++)
{
for(int d=0; d<n; d++)
{
cout<<e[d][j]<<"\t";
}
cout<<"\n";
}
system("PAUSE");
return 0;
}