-
Notifications
You must be signed in to change notification settings - Fork 1
/
Cardgame.cpp
38 lines (35 loc) · 919 Bytes
/
Cardgame.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "stdafx.h"
#include<iostream>
#include<conio.h>
#include<ctime> //needed for getRand
using namespace std;
#include"cards.cpp"
int _tmain(int argc, _TCHAR* argv[])
{
int getRand(); //Get a random number under 52
int rand; //See above
const int ALLCARDS = 52;
int split[ALLCARDS] = {0}; //Keeps track of who has what card: 0 is not used, 1 is player, 2 is computer
int playerScore = 0;
int comScore = 0;
int i;
srand((unsigned)time(NULL));
for(i = 0;i <26;i++){
rand = getRand();
cout<<rand<<' ';
if(split[rand] = 0)split[rand]=1;
//else{
// //while(split[rand] = 1 || split[rand] = 2)rand = getRand();
// //split[rand]=2;
// i--;
// }
}
for(i = 0;i < ALLCARDS;i++)cout<<split[i]; //52 1s and 0s Should be only 26 1s here
_getch();
return 0;}
int getRand(){
const int DIVISOR = 52;
int result;
result = rand() % DIVISOR;
return result;
}