The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.34 / 5.00 31,296 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.07 / 5.00 10,082 Viewsin this code it says that there are 2 else statements without matching if statements. can somebody tell me where this is true? please help with this.
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
int main()
{
srand( (unsigned)time( NULL ) );
int rps;
int random = (rand()%21);
cout<<"Rock, Paper, Scissors"<<endl;
cout<<"---------------------"<<endl;
cout<<"--By Steven Fowler.--"<<endl;
cout<<"--Press 1 For Rock,--"<<endl;
cout<<"--Press 2 For Paper--"<<endl;
cout<<"-And 3 For Scissors.-"<<endl;
cin>>rps;
if(random <= 6){
if(rps == 1){
cout<<"Computer Chooses Rock"<<endl;
cout<<"The Game Is Tied, Exit And Re-Run to Play Again"<<endl;
cin.ignore();
cin.ignore();
return 0;
}else{
if(rps == 2){
cout<<"Computer Chooses Rock"<<endl;
cout<<"You Win! Exit And Re-Run To Play Again"<<endl;
cin.ignore();
cin.ignore();
return 0;
}else{
if(rps == 3){
cout<<"Computer Chooses Rock"<<endl;
cout<<"You Lose! Exit And Re-Run To Play Again"<<endl;
cin.ignore();
cin.ignore();
return 0;
}
}
}else{
if(random <= 13){
if(rps == 1){
cout<<"Computer Chooses Paper"<<endl;
cout<<"You Lose! Exit And Re-Run to Play Again"<<endl;
cin.ignore();
cin.ignore();
return 0;
}else{
if(rps == 2){
cout<<"Computer Chooses Rock"<<endl;
cout<<"The Game Tied! Exit And Re-Run To Play Again"<<endl;
cin.ignore();
cin.ignore();
return 0;
}else{
if(rps == 3){
cout<<"Computer Chooses Rock"<<endl;
cout<<"You Win! Exit And Re-Run To Play Again"<<endl;
cin.ignore();
cin.ignore();
return 0;
}
}else{
if(random <= 20){
if(rps == 1){
cout<<"Computer Chooses Scissors"<<endl;
cout<<"You Win! Exit And Re-Run to Play Again"<<endl;
cin.ignore();
cin.ignore();
return 0;
}else{
if(rps == 2){
cout<<"Computer Chooses Rock"<<endl;
cout<<"You Lose! Exit And Re-Run To Play Again"<<endl;
cin.ignore();
cin.ignore();
return 0;
}else{
if(rps == 3){
cout<<"Computer Chooses Rock"<<endl;
cout<<"You Have Tied! Exit And Re-Run To Play Again"<<endl;
cin.ignore();
cin.ignore();
return 0;
}else{
return 0;
}
}
}
}
}
}
}
}
}
}
You really should use comments to help with this.
Example:
} //END IF
Youve made that whole code so hard to read/understand I coudld be wrong, but I think that second last } doesnt do anything. I couldnt find the specific problem though.
At 1/27/05 10:19 PM, eh-productions wrote: in this code it says that there are 2 else statements without matching if statements.
Hahaha, that's what you get for putting the whole program in main(). I hope you learn a lesson from this.
I was about to say the same thing. Learn how to use some functions and how to pass values between functions. Extremely easy and very very helpful.
this works for me. i don't care if others can read it very well its not my problem. plus i have only had c++ for one month and only read about it about 2 hours every weekend.