General Stuff > C,C++
Rock paper scissors!
|-|Java()|-|:
Well, here's rock paper scissors in C++. Made in like 5 mins.
--- Code: ---/*Script in C++. Rock paper sicrrors!. Enjoy.*/
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand((unsigned)time(0));
int choice;
int againchoice;
int computerchoice = (rand()%2)+1;
cout <<"Type 0 for Rock, 1 for Paper and 2 for Scissors.\n";
cin >> choice;
if (choice == 0)
{
if (computerchoice == 0)
cout << "It has resulted in a Tie!\n\n";
else if (computerchoice == 1)
cout << "Paper has beaten Rock. You have lost!\n\n";
else if (computerchoice == 2)
cout << "Rock has beaten Scissors. You have won!\n\n";
}
if (choice == 1)
{
if (computerchoice == 0)
cout << "It has resulted in a Tie!\n\n";
else if (computerchoice == 1)
cout << "Paper has beaten Rock. You have won!\n\n";
else if (computerchoice == 2)
cout << "Scissors has beaten Paper. You have lost!\n\n";
}
if (choice == 2)
{
if (computerchoice == 0)
cout << "It has resulted in a Tie!\n\n";
else if (computerchoice == 1)
cout << "Scissors has beaten Paper. You have won\n\n";
else if (computerchoice == 2)
cout << "Rock has beaten Scissors. You have lost!\n\n";
}
cout << "Would you like to play again? 1 for Yes and 2 for No.\n";
cin >> againchoice;
if (againchoice == 1)
{
system("cls");
return main();
}
else if (againchoice == 2)
{
system("EXIT");
}
}
--- End code ---
Can't compile? I'll upload the .exe. (C++ compiles to .exe)
http://www.megaupload.com/?d=5ZX82RC6
Yes, it's clean. Scan yourself. I'm not uploading scan results to proove it is clean.
Jessie:
So you get to play Rock Paper Scissors? I don't understand...
Kalphiter:
I actually never never never knew that C++ compiles to .exe. I was wondering for a very long time :D
Suki The Saluki:
Um what exactly do we put this in? i am confused
Kalphiter:
--- Quote from: Agent Z ™ on July 22, 2008, 10:27:56 am ---Um what exactly do we put this in? i am confused
--- End quote ---
Lol?
He said if you can't compile upload the .exe
Navigation
[0] Message Index
[#] Next page
Go to full version