Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main(void)
- {
- int input;
- int output;
- int computer;
- int again = 1;
- srand(time(NULL));
- while( again == 1) // commencement of while loop
- {
- //computer = rand();
- printf("Welcome to the hit new game: Rock-Paper-Scissors-Lizard-Spock!\n");
- printf("\nPress 1 to play Rock.\n");
- printf("\nPress 2 to play Paper.\n");
- printf("\nPress 3 to play Scizzors.\n");
- printf("\nPress 4 to play Lizard.\n");
- printf("\nPress 5 to play Spock.\n");
- printf("\nPlease make a selection\n");
- output = scanf( "%d" , &input);// reads player's input and stores value in the input variable
- computer = 6;
- if (output != 1)
- {
- fflush(stdin);
- printf(" Thanks for playing... Goodbye\n");
- again = 0; //Kills the while loop
- }
- else if (input == 1)
- {
- computer = rand() % 5 + 1;
- printf("You have selected Rock!\n");
- }
- if (computer == 1)
- {
- printf("I got rock and we tied\n");
- }
- else if (computer == 2)
- {
- printf("I got paper and I won\n");
- }
- else
- {
- printf("I got scissors and you won\n");
- } // end of else if input is rock
- else if (input == 2)
- {
- computer = rand() % 5 + 1;
- printf("You have selected paper\n");
- }
- }// end of while
- getchar();
- printf(" Goodbye...");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement