Advertisement
payjack

card game

Nov 14th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. //olivia
  2. //simple card game
  3.  
  4. #include <iostream>
  5. #include <time.h>
  6. #include <stdlib.h>
  7. using namespace std;
  8.  
  9. int main ()
  10. {
  11.  
  12.     int p1[10], p2 [10];
  13.     int newnumber1;
  14.     int newnumber2;
  15.     srand(time(NULL));
  16.     int score1=0;
  17.     int score2=0;
  18.     int winner;
  19.  
  20. cout<<"Welcome to my ~Card Game~ get ready for a fun game! :)"<<endl;
  21.  
  22.     for (int i=0; i<=11; i++)
  23.     {
  24.         cout<<"Round "<<i<<endl;
  25.         newnumber1 = rand()%14;
  26.         cout<<"Player 1 drew this card: "<<newnumber1<<endl;
  27.         newnumber2 = rand()%14;
  28.         cout<<"Player 2 drew this card: "<<newnumber2<<endl;
  29.  
  30.             if (p1 [i] > p2 [i])
  31.                 {
  32.                     score1=score1 +1;
  33.                     cout<<"Player 1 wins the round! They have been awarded 1 point!"<<endl;
  34.                 }
  35.             if (p1 [i] < p2 [i])
  36.                 {
  37.                     score2=score2 +1;
  38.                     cout<<"Player 2 wins the round! They have been awarded 1 point!"<<endl;
  39.                 }
  40.     }
  41.     if (score1>score2)
  42.     {
  43.         winner=1;
  44.     }
  45.     if (score1<score2)
  46.     {
  47.         winner=2;
  48.     }
  49.  
  50. cout<<"Well, that was fun! :) Here are the final scores! Player 1 has "<<score1<<"points!! Player 2 has "<<score2<<" points!!"<<endl;
  51. cout<<"The winner of this game is....Player "<<winner<<"!!!!!"<<endl;
  52.  
  53. return 0;
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement