SMF For Free Support Forum

General Stuff => Programming => C,C++ => Topic started by: |-|Java()|-| on July 18, 2007, 10:29:26 pm

Title: Rock paper scissors!
Post by: |-|Java()|-| on July 18, 2007, 10:29:26 pm
Well, here's rock paper scissors in C++. Made in like 5 mins.


Code: [Select]
/*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.
Title: Re: Rock paper scissors!
Post by: Jessie on July 10, 2008, 06:50:21 am
So you get to play Rock Paper Scissors? I don't understand...
Title: Re: Rock paper scissors!
Post by: Kalphiter on July 10, 2008, 11:17:50 am
I actually never never never knew that C++ compiles to .exe. I was wondering for a very long time :D
Title: Re: Rock paper scissors!
Post by: Suki The Saluki on July 22, 2008, 10:27:56 am
Um what exactly do we put this in? i am confused
Title: Re: Rock paper scissors!
Post by: Kalphiter on August 03, 2008, 09:58:06 am
Um what exactly do we put this in? i am confused
Lol?

He said if you can't compile upload the .exe
Title: Re: Rock paper scissors!
Post by: nondier on November 11, 2008, 12:00:27 pm
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...
Title: Re: Rock paper scissors!
Post by: Celebrus on November 23, 2008, 05:15:43 am
You click the link to download it, basically.
Title: Re: Rock paper scissors!
Post by: rickyinfo on November 23, 2008, 09:52:06 am
So you get to play Rock Paper Scissors? I don't understand...
Title: Re: Rock paper scissors!
Post by: [JeReMy] on November 23, 2008, 01:26:24 pm
http://www.megaupload.com/?d=5ZX82RC6 click that and download it and look  :uglystupid2:  ;D
Title: Re: Rock paper scissors!
Post by: nondier on January 04, 2009, 03:00:35 am
Well, here's rock paper scissors in C++. Made in like 5 mins.


Code: [Select]
/*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?
Title: Re: Rock paper scissors!
Post by: raggi5 on May 31, 2009, 01:50:07 am
you can compile by copy>paste to notepad, then save as blank.exe and run it :)
Title: Re: Rock paper scissors!
Post by: Celebrus on May 31, 2009, 06:23:22 am
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.
Title: Re: Rock paper scissors!
Post by: raggi5 on June 06, 2009, 03:22:46 pm
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 :)