English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

#include
#include
void yourturn(int&total){
int request;
do{
cout<<"There are "< cin>>request;
if((request<3||request>1)||(request cout<<"Value must be between 1 and 3"< cout<<"How many would you like?"< cin>>request;
}
}while((request<3||request>1)||(request total-=request;
return;
}
void myturn(int&total){
randomize();
int myrequest;
if (total>4){
cout<<"There are "< myrequest=random (3)+1;
cout< }
if (total==4){
cout<<"There are "< myrequest=3;
cout< }
total-=myrequest;
return;
}
int main(){
randomize();
int total=random(30)+15;
while(char answer='Y'){
yourturn(total);
if(total==1){
cout<<"THE COMPUTER WINS YOU NOOB";
}
myturn(total);
if(total=1){
cout<<"Ok...you beat the computer, woopdidoo";

2006-11-30 12:09:01 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

}
}
cout<<"Play again (Y) or (N)";
return 0;
}

2006-11-30 12:09:22 · update #1

1 answers

I have not tried to execute the program, but I think the following statement has an issue:
In function yourturn(),
if( (request < 3 || request >1) ..
ask the user to enter a value between 1 and 3.

If the user enters a valid value like 2, say, then the program would be asking him to re-enter the value.

Instead the check could be something like this:
if( (request < 1 || request >3) ...

This would make sure that you are checking for the correct range.

HTH.

2006-11-30 13:53:48 · answer #1 · answered by swami060 3 · 1 0

fedest.com, questions and answers