Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main(void)
  6. {
  7. int input;
  8. int output;
  9. int computer;
  10. int again = 1;
  11. srand(time(NULL));
  12.  
  13. while( again == 1) // commencement of while loop
  14. {
  15. //computer = rand();
  16.  
  17. printf("Welcome to the hit new game: Rock-Paper-Scissors-Lizard-Spock!\n");
  18. printf("\nPress 1 to play Rock.\n");
  19. printf("\nPress 2 to play Paper.\n");
  20. printf("\nPress 3 to play Scizzors.\n");
  21. printf("\nPress 4 to play Lizard.\n");
  22. printf("\nPress 5 to play Spock.\n");
  23. printf("\nPlease make a selection\n");
  24.  
  25. output = scanf( "%d" , &input);// reads player's input and stores value in the input variable
  26.  
  27.  
  28.  
  29. computer = 6;
  30.  
  31.  
  32. if (output != 1)
  33. {
  34. fflush(stdin);
  35. printf(" Thanks for playing... Goodbye\n");
  36. again = 0; //Kills the while loop
  37. }
  38. else if (input == 1)
  39. {
  40. computer = rand() % 5 + 1;
  41. printf("You have selected Rock!\n");
  42. }
  43.  
  44. if (computer == 1)
  45. {
  46. printf("I got rock and we tied\n");
  47.  
  48. }
  49.  
  50. else if (computer == 2)
  51. {
  52. printf("I got paper and I won\n");
  53. }
  54.  
  55. else
  56. {
  57. printf("I got scissors and you won\n");
  58. } // end of else if input is rock
  59.  
  60.  
  61. else if (input == 2)
  62. {
  63. computer = rand() % 5 + 1;
  64. printf("You have selected paper\n");
  65. }
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. }// end of while
  75.  
  76. getchar();
  77. printf(" Goodbye...");
  78. return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement