hello, i'm new member here and not so familiar with the forum here, there's something i wanna ask, i'm creating a game called deal or no deal using c++, may i know how to assign the random number to the boxes and output the boxes's number instead of the values assigned to it? and how to arrange the box separately? for i tried but it seems to stick together.
here's my code:
#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
double box[26];
srand( time(NULL) );
double amount_in_box[26]={.01,1,5,10,25,50,75,100,200,300,400,500,750,1000,5000,10000,25000,50000,75000,100000,200000,300000,400000,500000,750000,1000000};
for(int i=0; i<26; i++)
{
int RandIndex=rand() % 26;
box[i]=amount_in_box[RandIndex];
cout<<box[i]<<endl;
}
}
this is the boxes:
#include<iostream>
using namespace std;
int main()
{
int box[26]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,
14,15,16,17,18,19,20,21,22,23,24,25,26};
for( int i=0; i<26; i++)
{
cout<<" "<<"|"<<box[i]<<"|";
}
}
the part for display box, when i use endl it cout in a straight line, when i use set.width(5), set. precision(2) and cout.setf(ios::fixed); before the cout<<" "<< "|"<