Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. #include<time.h>
  5.  
  6. /*
  7. Exam 2 -- Program 2;
  8.     program that plays the game pick 4 with the user
  9.  
  10.     Written by Daniel Lund, Houssam Haj,
  11.     Haneul Choi and Calvin Shaw
  12.     Feb. 23th, 2019
  13. */
  14.  
  15. void main()
  16. {
  17.     int b1,b2,b3,b4,d1, d2, d3, d4, win;
  18.    
  19.         printf("Enter the four numbers ");
  20.         scanf("%d %d %d %d",&d1, &d2, &d3, &d4);
  21.         time_t t;
  22.         srand((unsigned)time(&t));
  23.         b1 = rand() % 9 + 1;
  24.         b2 = rand() % 9 + 1;
  25.         b3 = rand() % 9 + 1;
  26.         b4 = rand() % 9 + 1;
  27.        
  28.         printf("\n\n%d %d %d %d\n\n",b1,b2,b3,b4);
  29.        
  30.         if (d1 == b1 && d2 == b2 ||  d1 == b1 && d3 == b3 || d1 == b1 && d4 == b4 || d2 == b2 && d3 == b3 || d2 == b2 && d4 == b4 || d3 == b3 && d4 == b4)
  31.         {
  32.             win = d1 + d2 + d3 + d4;
  33.             printf("\n\nTwo numbers mutched\n\n");
  34.             printf("\n\nYou win %d\n\n", win);
  35.         }
  36.            
  37.         else if (d1 == b1 && d2 == b2 && d3 == b3 || d1 == b1 && d2 == b2 && d4 == b4 || d1 == b1 && d3 == b3 && d4 == b4 || d2 == b2 && d3 == b3 && d4 == b4)
  38.         {
  39.             win = (d1 + d2 + d3 + d4) * 2;
  40.             printf("\n\nThree numbers mutched\n\n");
  41.             printf("\n\nYou win\n\n",win);
  42.         }
  43.         else if (d1 == b1 && d2 == b2 && d3 == b3 && d4 == b4)
  44.         {
  45.             win = (d1 + d2 + d3 + d4) * 5;
  46.             printf("\n\nFour numbers mutched\n\n");
  47.             printf("\n\nYou win\n\n", win);
  48.         }
  49.         else printf("\n\nYou lose\n\n");
  50.            
  51.     system("PAUSE");
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement