This week's book giveaway is in the Java in General forum.
We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

want to display the following output?

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
lets say the number of inputs is 3
i,j,k
range for them are 0-100, 2-200, and 3-300 (Range : Min Value-Max Value)
then the output should come
0 2 3
1 2 3
50 2 3
99 2 3
100 2 3
0 3 3
1 3 3
50 3 3
99 3 3
100 3 3
0 101 3
1 101 3
50 101 3
99 101 3
100 101 3
0 199 3
1 199 3
50 199 3
99 199 3
100 199 3
0 200 3
1 200 3
50 200 3
99 200 3
100 200 3
then first two columns repeat with 4 in last column
then 3+300/2 in last column
then 299 in last column
then 300 in last column


I would appreciate a hint and not the entire solution.
Thanks

This is the table generated for Worst Case Testing.
 
Andrew Musgrave
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this program is to be coded in c++
 
Sheriff
Posts: 28344
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your problem that you don't know how to program this in C++, or that you don't know how to program it?
 
Andrew Musgrave
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
}
 
Andrew Musgrave
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
basically the output should be in the form i presented in the first post
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic