Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

Code Bank


ghost's Avatar
0 0

I didn't see anywhere to submit code to the code bank, so I'm going to post it here. This is basically a Rock, Paper Scissors game written in C++

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
    srand((unsigned)time(0));
    int choice;
    int compchoice = rand()%3;
    cout << "Welcome to ~ Rock Paper Scissors ~!! I assume you know how to play,";
    cout << " so lets begin. You are playing against the computer. Type 0 for";
    cout << " rock, 1 for paper, and 2 for scissors\n";
    cin >> choice;
    
    if (choice == 0) 
    {
              if (compchoice == 0)
              cout << "It's a tie!\n\n\n\n";
              else if (compchoice == 1)
              cout << "Paper beats rock! Sorry, you lose!\n\n\n\n";
              else if (compchoice == 2)
              cout << "Rock beats scissors! You win!\n\n\n\n";
    }
    
    if (choice == 1)
    {
               if (compchoice == 0)
               cout << "It's a tie!\n\n\n\n";
               else if (compchoice == 1)
               cout << "Paper beats rock! You win!\n\n\n\n";
               else if (compchoice == 2)
               cout << "Scissors beat paper! Sorry, you lose!\n\n\n\n";
   }
   
   if (choice == 2)
   {
              if (compchoice == 0)
              cout << "It's a tie!\n\n\n\n";
              else if (compchoice == 1)
              cout << "Scissors beat paper! You win!\n\n\n\n";
              else if (compchoice == 2)
              cout << "Rock beats scissors! Sorry, you lose!\n\n\n\n";
   }
   cout << "Press enter to play again...\n";
   cin.get();
   cin.get();
   system("cls");
   return main();
}



ghost's Avatar
0 0

submit code is right under the submit section on the right side lol


ghost's Avatar
0 0

Nice work… :p


ghost's Avatar
0 0

sorry, you can delete this thread


ghost's Avatar
0 0

I'm doing the exact thing in my ICTP class next week.:D


ghost's Avatar
0 0

Lol, well, you can use this if you want…