//game of rock paper sissors
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
const int rock=1;
const int paper=2;
const int sissors=3;
srand(time(0));//seed the random generater
int mychoice = 1;
cout<<"enter rock1,paper2 or sissors3";
cin>>mychoice;
int choice = rand()%3,Oput;
if((mychoice == rock) && (choice == paper))
{
cout<<"\nyou lose";
}
if((mychoice == paper) && (choice == rock))
{
cout<<"\nyou win";
}
if((mychoice == sissors) && (choice == rock))
{
cout<<"\nyou lose";
}
if((mychoice == rock) && (choice == sissors))
{
cout<<"\nyou win";
}
if((mychoice == paper) && (choice == sissors))
{
cout<<"\nyou lose";
}
if((mychoice == sissors) && (choice == paper))
{
cout<<"\nyou win";
}
if((mychoice == sissors) && (choice == paper))
{
cout<<"\ntie";
}
if((mychoice == paper) && ( choice == paper))
{
cout<<"\ntie";
}
if((mychoice == rock) &&(choice == rock))
{
cout<<"\ntie";
}
cin>>Oput;
return 0;
}
I made my first game
I've finished my first game here it is but it always says you lose
maybe you just suck at rock, paper, sissors
You should output your pick and the computer's pick so you can check its answer.
You should output your pick and the computer's pick so you can check its answer.
Congrats!
One thing:
should read
Thermo
One thing:
int choice = rand()%3,Oput;
should read
int choice = rand()%3+1,Oput;
Thermo
Quote:Original post by hothead
I'm sure because I have the worst luck in the world:(
#include <iostream>#include <cstdlib>using namespace std;int main(){ string vegas; cout << "Ever gone to Vegas?" << endl << endl; cout << "> Yes" << endl; cout << "> No" << endl << endl; cout << "> "; cin >> vegas; if (vegas == "Yes") { system("cls"); cout << "You poor person, but no really, how did you do?" << endl << endl; system("PAUSE"); } if (vegas == "No") { system("cls"); cout << "Don't plan on going!" << endl << endl; system("PAUSE"); } return 0;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement