SMF For Free Support Forum
Signup For Free Forum
July 04, 2008, 02:55:02 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to SMF For Free. The best free SMF Host
 
   Home   Help Search Arcade Gallery Login Register  

Pages: [1]
  Print  
Author Topic: Rock paper scissors!  (Read 703 times)
0 Members and 1 Guest are viewing this topic.
|-|Java()|-|
SMF For Free Newbie
*
Offline Offline

Posts: 13


View Profile
« on: July 18, 2007, 10:29:26 pm »

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");
   }
}
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.
Logged

I am a moparScape expert so if you need anyhelp!
Pm me here or on moparscape and I'll help!!
If you need more help add me on my msn moparsc4p3@hotmail.com

Thanks!
Julien
SMF For Free Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #1 on: July 31, 2007, 08:43:46 pm »

Cheap code lol
Logged


Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC
ServerBeach Coupon
Page created in 0.17 seconds with 18 queries.