SMF For Free Support Forum
General Stuff => Programming => C,C++ => Topic started by: |-|Java()|-| on July 18, 2007, 10:29:26 pm
-
Well, here's rock paper scissors in C++. Made in like 5 mins.
/*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");
}
}
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.
-
So you get to play Rock Paper Scissors? I don't understand...
-
I actually never never never knew that C++ compiles to .exe. I was wondering for a very long time :D
-
Um what exactly do we put this in? i am confused
-
Um what exactly do we put this in? i am confused
Lol?
He said if you can't compile upload the .exe
-
Um what exactly do we put this in? i am confused
Lol?
He said if you can't compile upload the .exe
That Doesn't tell me anything..lol...
-
You click the link to download it, basically.
-
So you get to play Rock Paper Scissors? I don't understand...
-
http://www.megaupload.com/?d=5ZX82RC6 click that and download it and look :uglystupid2: ;D
-
Well, here's rock paper scissors in C++. Made in like 5 mins.
/*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");
}
}
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.
anyway we can do this without downloading?
-
you can compile by copy>paste to notepad, then save as blank.exe and run it :)
-
you can compile by copy>paste to notepad, then save as blank.exe and run it :)
Was that sarcasm?
If not, did you actually try doing that? Did it work?
In reality, you'd need a compiler. mingw is a really nice one.
-
you can compile by copy>paste to notepad, then save as blank.exe and run it :)
Was that sarcasm?
If not, did you actually try doing that? Did it work?
In reality, you'd need a compiler. mingw is a really nice one.
actually no, it worked for me :)