Help with blackjack code

Hello, I am writing a code that, when the cards you have, and the dealers up card are inputed in the machine,
tells you the best decision to make in a game of blackjack. However my code does not work, it compiles well,
but after the numbers are inputed, it closes down. Can someone please evaluate this code,
and tell me what is wrong with it, I am using a Dev-C++ compiler.

P.S. I would also like to make the program shorter, if anyone could help with that also.

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#include <iostream>

using namespace std;

int d;
int y;


int main()
{
    cout<<"Hello! My name is BrandtBot, Please enter the Dealer's First Card\nDo not use faces, enter them as 10\nTo enter an ace, enter 1";
    cin>> d; 
    cin.ignore(); 
    cout<<"Please enter your hand as a number.\nIf you have a soft hand, enter a 1 after the number\nFor example, a soft 20 is 201.\nIf you have a pair, enter a 2 after the number that represents the card\nFor example a pair of aces would be 12"; 
    cin>> y; 
    cin.ignore(); 
    cin.get(); 
    if (d == 2 && y >= 13)
    cout<<"Stand";
    if (d == 2 && y == 11 || y == 10)
    cout<<"Double Down";
    if (d == 2 && y <= 9 || y == 12)
    cout<<"Hit";
    if (d == 3 && y >= 13)
    cout<<"Stand";
    if (d == 3 && y == 11 || y == 10 || y == 9)
    cout<<"Double Down";
    if (d == 3 && y <= 8 || y == 12)
    cout<<"Hit";
    if (d == 4 && y >= 12)
    cout<<"Stand";
    if (d == 4 && y == 11 || y == 10 || y == 11 || y == 9)
    cout<<"Double Down";
    if (d == 4 && y <= 8)
    cout<<"Hit";
    if (d == 5 && y >= 12)
    cout<<"Stand";
    if (d == 5 && y == 11 || y == 10 || y == 9)
    cout<<"Double Down";
    if (d == 5 && y <= 8)
    cout<<"Hit";
    if (d == 6 && y >= 12)
    cout<<"Stand";
    if (d == 6 && y == 11 || y == 10 || y == 9)
    cout<<"Double Down";
    if (d == 6 && y <= 8)
    cout<<"Hit";
    if (d == 7 && y >= 16)
    cout<<"Stand";
    if (d == 7 && y == 11 || y == 10)
    cout<<"Double Down";
    if (d == 7 && y <= 9 || y == 15 || y == 14 || y == 13 || y == 12)
    cout<<"Hit";
    if (d == 8 && y >= 16)
    cout<<"Stand";
    if (d == 8 && y == 15 || y == 14 || y == 13 || y == 12 || y <= 9)
    cout<<"Hit";
    if (d == 8 && y == 11 || y == 10)
    cout<<"Double Down";
    if (d == 9 && y >= 16)
    cout<<"Stand";
    if (d == 9 && y == 15 || y == 14 || y == 13 || y == 12 || y <= 9)
    cout<<"Hit";
    if (d == 9 && y == 11 || y == 10)
    cout<<"Double Down";
    if (d == 10 && y >= 16)
    cout<<"Stand";
    if (d == 10 && y == 15 || y == 14 || y == 13 || y == 12 || y <= 10)
    cout<<"Hit";
    if (d == 10 && y == 11)
    cout<<"Double Down";
    if (d == 1 && y >= 16)
    cout<<"Stand";
    if (d == 1 && y <= 15)
    cout<<"Hit";
    if (d == 2 && y >= 181)
    cout<<"Stand";
    if (d == 2 && y <= 171)
    cout<<"Hit";
    if (d == 3 && y >= 191)
    cout<<"Stand";
    if (d == 3 && y == 181 || y == 171)
    cout<<"Double";
    if (d == 3 && y <= 161)
    cout<<"Hit";
    if (d == 4 && y >= 191)
    cout<<"Stand";
    if (d == 4 && y == 181 || y == 171 || y == 161 || y == 151)
    cout<<"Double";
    if (d == 4 && y <= 141)
    cout<<"Hit";
    if (d == 5 && y >= 191)
    cout<<"Stand";
    if (d == 5 && y <= 181)
    cout<<"Double";
    if (d == 6 && y >= 191)
    cout<<"Stand";
    if (d == 6 && y <= 181)
    cout<<"Double";
    if (d == 7 && y >= 181)
    cout<<"Stand";
    if (d == 7 && y <= 171)
    cout<<"Hit";
    if (d == 8 && y >= 181)
    cout<<"Stand";
    if (d == 8 && y <= 171)
    cout<<"Hit";
    if (d == 9 && y >= 191)
    cout<<"Stand";
    if (d == 9 && y <= 181)
    cout<<"Hit";
    if (d == 10 && y >= 191)
    cout<<"Stand";
    if (d == 10 && y <= 181)
    cout<<"Hit";
    if (d == 1 && y >= 191)
    cout<<"Stand";
    if (d == 1 && y <= 181)
    cout<<"Hit";
    if (d == 2 && y == 12 || y == 92 || y == 82 || y == 72 || y == 62 || y <= 32)
    cout<<"Split";
    if (d == 2 && y == 102)
    cout<<"Stand";
    if (d == 2 && y == 52)
    cout<<"Double";
    if (d == 2 && y == 42)
    cout<<"Hit";
    if (d == 3 && y == 102)
    cout<<"Stand";
    if (d == 3 && y == 52)
    cout<<"Double";
    if (d == 3 && y == 42)
    cout<<"Hit";
    if (d == 3 && y <= 32 || y == 12 || y == 92 || y == 82 || y == 72 || y == 62)
    cout<<"Split";
    if (d == 4 && y == 102)
    cout<<"Stand";
    if (d == 4 && y == 52)
    cout<<"Double";
    if (d == 4 && y == 42)
    cout<<"Hit";
    if (d == 4 && y <= 32 || y == 12 || y == 92 || y == 82 || y == 72 || y == 62)
    cout<<"Split";
    if (d == 5 && y == 102)
    cout<<"Stand";
    if (d == 5 && y == 52)
    cout<<"Double";
    if (d == 5 && y <= 42 || y == 12 || y == 92 || y == 82 || y == 72 || y == 62)
    cout<<"Split";
    if (d == 6 && y == 102)
    cout<<"Stand";
    if (d == 6 && y == 52)
    cout<<"Double";
    if (d == 6 && y <= 42 || y == 12 || y == 92 || y == 82 || y == 72 || y == 62)
    cout<<"Split";
    if (d == 7 && y == 12 || y == 82 || y == 72 || y ==32 || y == 22)
    cout<<"Split";
    if (d == 7 && y == 102 || y == 92)
    cout<<"Stand";
    if (d == 7 && y == 62 || y == 42)
    cout<<"Hit";
    if (d == 7 && y == 52)
    cout<<"Double";
    if (d == 8 && y == 12 || y == 92 || y == 82)
    cout<<"Split";
    if (d == 8 && y == 102)
    cout<<"Stand";
    if (d == 8 && y == 72 || y == 62 || y == 42)
    cout<<"Hit";
    if (d == 8 && y == 52)
    cout<<"Double";
    if (d == 9 && y == 12 || y == 92 || y == 82)
    cout<<"Split";
    if (d == 9 && y == 102)
    cout<<"Stand";
    if (d == 9 && y == 72 || y == 62 || y == 42)
    cout<<"Hit";
    if (d == 9 && y == 52)
    cout<<"Double";
    if (d == 10 && y == 12 || y == 82)
    cout<<"Split";
    if (d == 10 && y == 102 || y == 92)
    cout<<"Stand";
    if (d == 10 && y == 72 || y == 62 || y == 52 || y == 42 || y == 32 || y == 22)
    cout<<"Hit";
    if (d == 1 && y == 12 || y == 82)
    cout<<"Split";
    if (d == 1 && y == 102 || y == 92)
    cout<<"Stand";
    if (d == 1 && y == 72 || y == 62 || y == 52 || y == 42 || y == 32 || y == 22)
    cout<<"Hit";
    return 1;
} 
Last edited on
You already have a post going, but instead of using ints, why not use decimals to indicate a pair, or have the user enter individual cards, card1 and card2?
You have a lot of times where you evaluate d and then give conflicting cases for y, such as line 72 and 118. Can't really help too much until this makes sense.

The reason the console quits is because your program is over. Put a cin.get(); after line 191. If that doesn't work, put cin.ignore(80, '\n'); right before it.

I did a little before I realized all of the craziness in there. I would recommend a switch case:

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
switch (d)
{
case 1:  // In the case that d == 1
  if (y % 10 == 2)  // this separates lines 168 through 190
  {
    switch (y)
    {
    case 12:
    case 82:  cout << "Split"; break;  // Both 12 and 82 get here
    case 92:
    case 102: cout << "Stand"; break;
    default: cout << "Hit";  // Everything else gets here
  }
  else if....
  // Here you have inconsistent results for values of y. Look at line 72 and 118
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
default:
}
Last edited on
Switch case was the first thing I was gonna recommend after just reading through it :3.^^^^
About the conflicting cases. Your asking the user to enter a trailing 1 after the hand number if the user has a soft hand, and a 2 if the user has a pair.

If the number is less than or equal to 21, you can assume it's neither a pair or a soft hand. You cannot have a number of 1, so 11 could only mean a hand number of 11. 21 cannot mean a soft hand number of 2 because a 2 is two aces, and thats a pair, -> 22.

And if they entered a number greater than 21, then you can assume it is a soft hand or they have a pair. You can differentiate between the two exploiting the fact that if it ends in a 2, then it's even, and if it ends in a 1, then its odd. So you can check just check if the number is even or odd.

Anyways, you can break your program up like this,

1
2
3
4
5
6
7
8
if (y > 2 && y < 22) { //then you know they don't have a soft hand or a pair
  //add your lines 18 through 75 
}
else if (y & 1){  //if it is not between 2 and 22, and the number is odd, then it must be a soft, so add your soft hand code 
// instead of if (y & 1) you can use if ((y % 2) != 0), meaning if their is a remainder when y is divided by 2
}
else{  //it must be a pair,  add your cases for pairs
}


Make sure to think over what i've written carefully, make sure you understand it, and evaluate for yourself, I may be wrong.

y & 1 is a bitwise operation.
http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/
Last edited on
iseeplusplus,

Thank you, your format did simplify my results, however I still get numerous results, for example if the dealers card is 2 and your hand is 14, I get
StandHitHItHitHit
How can I fix this?
iseeplusplus,

Thank you, your format did simplify my results, however I still get numerous results, for example if the dealers card is 2 and your hand is 14, I get
StandHitHItHitHit
How can I fix this?
Could you post what you have now?



Last edited on
here is what i have
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#include <iostream>

using namespace std;

int d;
int y;


int main()
{
    do 
    {

    cout<<"Hello! My name is BrandtBot, Please enter the Dealer's First Card\nDo not use faces, enter them as 10\nTo enter an ace, enter 1";
    cin>> d; 
    cin.ignore(); 
    cout<<"Please enter your hand as a number.\nIf you have a soft hand, enter a 1 after the number\nFor example, a soft 20 is 201.\nIf you have a pair, enter a 2 after the number that represents the card\nFor example a pair of aces would be 12"; 
    cin>> y; 
    cin.ignore(); 
    cin.get(); 
    if (y > 2 && y <= 22) { 
          if (d == 2 && y >= 13)
    cout<<"Stand";
    if (d == 2 && y == 11 || y == 10)
    cout<<"Double Down";
    if (d == 2 && y <= 9 || y == 12)
    cout<<"Hit";
    if (d == 3 && y >= 13)
    cout<<"Stand";
    if (d == 3 && y == 11 || y == 10 || y == 9)
    cout<<"Double Down";
    if (d == 3 && y <= 8 || y == 12)
    cout<<"Hit";
    if (d == 4 && y >= 12)
    cout<<"Stand";
    if (d == 4 && y == 11 || y == 10 || y == 11 || y == 9)
    cout<<"Double Down";
    if (d == 4 && y <= 8)
    cout<<"Hit";
    if (d == 5 && y >= 12)
    cout<<"Stand";
    if (d == 5 && y == 11 || y == 10 || y == 9)
    cout<<"Double Down";
    if (d == 5 && y <= 8)
    cout<<"Hit";
    if (d == 6 && y >= 12)
    cout<<"Stand";
    if (d == 6 && y == 11 || y == 10 || y == 9)
    cout<<"Double Down";
    if (d == 6 && y <= 8)
    cout<<"Hit";
    if (d == 7 && y >= 16)
    cout<<"Stand";
    if (d == 7 && y == 11 || y == 10)
    cout<<"Double Down";
    if (d == 7 && y <= 9 || y == 15 || y == 14 || y == 13 || y == 12)
    cout<<"Hit";
    if (d == 8 && y >= 16)
    cout<<"Stand";
    if (d == 8 && y == 15 || y == 14 || y == 13 || y == 12 || y <= 9)
    cout<<"Hit";
    if (d == 8 && y == 11 || y == 10)
    cout<<"Double Down";
    if (d == 9 && y >= 16)
    cout<<"Stand";
    if (d == 9 && y == 15 || y == 14 || y == 13 || y == 12 || y <= 9)
    cout<<"Hit";
    if (d == 9 && y == 11 || y == 10)
    cout<<"Double Down";
    if (d == 10 && y >= 16)
    cout<<"Stand";
    if (d == 10 && y == 15 || y == 14 || y == 13 || y == 12 || y <= 10)
    cout<<"Hit";
    if (d == 10 && y == 11)
    cout<<"Double Down";
    if (d == 1 && y >= 16)
    cout<<"Stand";
    if (d == 1 && y <= 15)
    cout<<"Hit";
}
else if (y & 1){ 
     if (d == 2 && y >= 181)
    cout<<"Stand";
    if (d == 2 && y <= 171)
    cout<<"Hit";
    if (d == 3 && y >= 191)
    cout<<"Stand";
    if (d == 3 && y == 181 || y == 171)
    cout<<"Double";
    if (d == 3 && y <= 161)
    cout<<"Hit";
    if (d == 4 && y >= 191)
    cout<<"Stand";
    if (d == 4 && y == 181 || y == 171 || y == 161 || y == 151)
    cout<<"Double";
    if (d == 4 && y <= 141)
    cout<<"Hit";
    if (d == 5 && y >= 191)
    cout<<"Stand";
    if (d == 5 && y <= 181)
    cout<<"Double";
    if (d == 6 && y >= 191)
    cout<<"Stand";
    if (d == 6 && y <= 181)
    cout<<"Double";
    if (d == 7 && y >= 181)
    cout<<"Stand";
    if (d == 7 && y <= 171)
    cout<<"Hit";
    if (d == 8 && y >= 181)
    cout<<"Stand";
    if (d == 8 && y <= 171)
    cout<<"Hit";
    if (d == 9 && y >= 191)
    cout<<"Stand";
    if (d == 9 && y <= 181)
    cout<<"Hit";
    if (d == 10 && y >= 191)
    cout<<"Stand";
    if (d == 10 && y <= 181)
    cout<<"Hit";
    if (d == 1 && y >= 191)
    cout<<"Stand";
    if (d == 1 && y <= 181)
    cout<<"Hit";
}
else{  
       if (d == 2 && y == 12 || y == 92 || y == 82 || y == 72 || y == 62 || y <= 32)
    cout<<"Split";
    if (d == 2 && y == 102)
    cout<<"Stand";
    if (d == 2 && y == 52)
    cout<<"Double";
    if (d == 2 && y == 42)
    cout<<"Hit";
    if (d == 3 && y == 102)
    cout<<"Stand";
    if (d == 3 && y == 52)
    cout<<"Double";
    if (d == 3 && y == 42)
    cout<<"Hit";
    if (d == 3 && y <= 32 || y == 12 || y == 92 || y == 82 || y == 72 || y == 62)
    cout<<"Split";
    if (d == 4 && y == 102)
    cout<<"Stand";
    if (d == 4 && y == 52)
    cout<<"Double";
    if (d == 4 && y == 42)
    cout<<"Hit";
    if (d == 4 && y <= 32 || y == 12 || y == 92 || y == 82 || y == 72 || y == 62)
    cout<<"Split";
    if (d == 5 && y == 102)
    cout<<"Stand";
    if (d == 5 && y == 52)
    cout<<"Double";
    if (d == 5 && y <= 42 || y == 12 || y == 92 || y == 82 || y == 72 || y == 62)
    cout<<"Split";
    if (d == 6 && y == 102)
    cout<<"Stand";
    if (d == 6 && y == 52)
    cout<<"Double";
    if (d == 6 && y <= 42 || y == 12 || y == 92 || y == 82 || y == 72 || y == 62)
    cout<<"Split";
    if (d == 7 && y == 12 || y == 82 || y == 72 || y ==32 || y == 22)
    cout<<"Split";
    if (d == 7 && y == 102 || y == 92)
    cout<<"Stand";
    if (d == 7 && y == 62 || y == 42)
    cout<<"Hit";
    if (d == 7 && y == 52)
    cout<<"Double";
    if (d == 8 && y == 12 || y == 92 || y == 82)
    cout<<"Split";
    if (d == 8 && y == 102)
    cout<<"Stand";
    if (d == 8 && y == 72 || y == 62 || y == 42)
    cout<<"Hit";
    if (d == 8 && y == 52)
    cout<<"Double";
    if (d == 9 && y == 12 || y == 92 || y == 82)
    cout<<"Split";
    if (d == 9 && y == 102)
    cout<<"Stand";
    if (d == 9 && y == 72 || y == 62 || y == 42)
    cout<<"Hit";
    if (d == 9 && y == 52)
    cout<<"Double";
    if (d == 10 && y == 12 || y == 82)
    cout<<"Split";
    if (d == 10 && y == 102 || y == 92)
    cout<<"Stand";
    if (d == 10 && y == 72 || y == 62 || y == 52 || y == 42 || y == 32 || y == 22)
    cout<<"Hit";
    if (d == 1 && y == 12 || y == 82)
    cout<<"Split";
    if (d == 1 && y == 102 || y == 92)
    cout<<"Stand";
    if (d == 1 && y == 72 || y == 62 || y == 52 || y == 42 || y == 32 || y == 22)
    cout<<"Hit";
} 
} while (1);
    return 0;
} 


if I add another ")" like you suggested, i get an error
Last edited on
You need to write these lines like this,

if (d == 4 && (y == 11 || y == 10 || y == 9) )

Notice the ( after the && also. This way your saying, if d == 4, and y is, 11, 10, or 9.

if (d == 4 && y == 11 || y == 10 || y == 9) // is wrong

The above says, if (d is 4 and y is 11) or if y is 10, or 9.
Last edited on
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#include <iostream>

using namespace std;

int d;
int y;


int main()
{
    do 
    {

        cout << "Hello! My name is BrandtBot, Please enter the Dealer's First Card\nDo not use faces, enter them as 10\nTo enter an ace, enter 1 :";
        cin>> d; 
    
        cout<< endl <<"Please enter your hand as a number.\nIf you have a soft hand, enter a 1 after the number\nFor example, a soft 20 is 201.\nIf you have a pair, enter a 2 after the number that represents the card\nFor example a pair of aces would be 12 :"; 
        cin>> y; 

	cout << endl;

        if (y > 2 && y < 22) { 
	        if (d == 2 && y >= 13)
			cout<< endl <<"Stand";
		if (d == 2 && (y == 11 || y == 10))
			cout<< endl <<"Double Down";
		if (d == 2 && (y <= 9 || y == 12))
			cout<< endl <<"Hit";
		if (d == 3 && y >= 13)
			cout<< endl <<"Stand";
		if (d == 3 && (y == 11 || y == 10 || y == 9))
			cout<< endl <<"Double Down";
		if (d == 3 && (y <= 8 || y == 12))
			cout<< endl <<"Hit";
		if (d == 4 && y >= 12)
			cout<< endl <<"Stand";
		if (d == 4 && (y == 11 || y == 10 || y == 11 || y == 9))
			cout<< endl <<"Double Down";
		if (d == 4 && y <= 8)
			cout<< endl <<"Hit";
		if (d == 5 && y >= 12)
			cout<< endl <<"Stand";
		if (d == 5 && (y == 11 || y == 10 || y == 9))
			cout<< endl <<"Double Down";
		if (d == 5 && y <= 8)
			cout<< endl <<"Hit";
		if (d == 6 && y >= 12)
			cout<< endl <<"Stand";
		if (d == 6 && (y == 11 || y == 10 || y == 9))
			cout<< endl <<"Double Down";
		if (d == 6 && y <= 8)
			cout<< endl <<"Hit";
		if (d == 7 && y >= 16)
			cout<< endl <<"Stand";
		if (d == 7 && y == 11 || y == 10)
			cout<< endl <<"Double Down";
		if (d == 7 && (y <= 9 || y == 15 || y == 14 || y == 13 || y == 12))
			cout<< endl <<"Hit";
		if (d == 8 && y >= 16)
			cout<< endl <<"Stand";
		if (d == 8 && (y == 15 || y == 14 || y == 13 || y == 12 || y <= 9))
			cout<< endl <<"Hit";
		if (d == 8 && (y == 11 || y == 10))
			cout<< endl <<"Double Down";
		if (d == 9 && y >= 16)
			cout<< endl <<"Stand";
		if (d == 9 && (y == 15 || y == 14 || y == 13 || y == 12 || y <= 9))
			cout<< endl <<"Hit";
		if (d == 9 && (y == 11 || y == 10))
			cout<< endl <<"Double Down";
		if (d == 10 && y >= 16)
			cout<< endl <<"Stand";
		if (d == 10 && (y == 15 || y == 14 || y == 13 || y == 12 || y <= 10))
			cout<< endl <<"Hit";
		if (d == 10 && y == 11)
			cout<< endl <<"Double Down";
		if (d == 1 && y >= 16)
			cout<< endl <<"Stand";
		if (d == 1 && y <= 15)
			cout<< endl <<"Hit";
	 }
	 else if (y & 1){ 
		if (d == 2 && y >= 181)
			cout<< endl <<"Stand";
		if (d == 2 && y <= 171)
			cout<< endl <<"Hit";
		if (d == 3 && y >= 191)
			cout<< endl <<"Stand";
		if (d == 3 && (y == 181 || y == 171))
			cout<< endl <<"Double";
		if (d == 3 && y <= 161)
			cout<< endl <<"Hit";
		if (d == 4 && y >= 191)
			cout<< endl <<"Stand";
		if (d == 4 && (y == 181 || y == 171 || y == 161 || y == 151))
			cout<< endl <<"Double";
		if (d == 4 && y <= 141)
			cout<< endl <<"Hit";
		if (d == 5 && y >= 191)
			cout<< endl <<"Stand";
		if (d == 5 && y <= 181)
			cout<< endl <<"Double";
		if (d == 6 && y >= 191)
			cout<< endl <<"Stand";
		if (d == 6 && y <= 181)
			cout<< endl <<"Double";
		if (d == 7 && y >= 181)
			cout<< endl <<"Stand";
		if (d == 7 && y <= 171)
			cout<< endl <<"Hit";
		if (d == 8 && y >= 181)
			cout<< endl <<"Stand";
		if (d == 8 && y <= 171)
			cout<< endl <<"Hit";
		if (d == 9 && y >= 191)
			cout<< endl <<"Stand";
		if (d == 9 && y <= 181)
			cout<< endl <<"Hit";
		if (d == 10 && y >= 191)
			cout<< endl <<"Stand";
		if (d == 10 && y <= 181)
			cout<< endl <<"Hit";
		if (d == 1 && y >= 191)
			cout<< endl <<"Stand";
		if (d == 1 && y <= 181)
			cout<< endl <<"Hit";
	}
	else{  
                if (d == 2 && (y == 12 || y == 92 || y == 82 || y == 72 || y == 62 || y <= 32))
			cout<< endl <<"Split";
		if (d == 2 && y == 102)
			cout<< endl <<"Stand";
		if (d == 2 && y == 52)
			cout<< endl <<"Double";
		if (d == 2 && y == 42)
			cout<< endl <<"Hit";
		if (d == 3 && y == 102)
			cout<< endl <<"Stand";
		if (d == 3 && y == 52)
			cout<< endl <<"Double";
		if (d == 3 && y == 42)
			cout<< endl <<"Hit";
		if (d == 3 && (y <= 32 || y == 12 || y == 92 || y == 82 || y == 72 || y == 62))
			cout<< endl <<"Split";
		if (d == 4 && y == 102)
			cout<< endl <<"Stand";
		if (d == 4 && y == 52)
			cout<< endl <<"Double";
		if (d == 4 && y == 42)
			cout<< endl <<"Hit";
		if (d == 4 && (y <= 32 || y == 12 || y == 92 || y == 82 || y == 72 || y == 62))
			cout<< endl <<"Split";
		if (d == 5 && y == 102)
			cout<< endl <<"Stand";
		if (d == 5 && y == 52)
			cout<< endl <<"Double";
		if (d == 5 && (y <= 42 || y == 12 || y == 92 || y == 82 || y == 72 || y == 62))
			cout<< endl <<"Split";
		if (d == 6 && y == 102)
			cout<< endl <<"Stand";
		if (d == 6 && y == 52)
			cout<< endl <<"Double";
		if (d == 6 && (y <= 42 || y == 12 || y == 92 || y == 82 || y == 72 || y == 62))
			cout<< endl <<"Split";
		if (d == 7 && (y == 12 || y == 82 || y == 72 || y ==32 || y == 22))
			cout<< endl <<"Split";
		if (d == 7 && (y == 102 || y == 92))
			cout<< endl <<"Stand";
		if (d == 7 && (y == 62 || y == 42))
			cout<< endl <<"Hit";
		if (d == 7 && y == 52)
			cout<< endl <<"Double";
		if (d == 8 && (y == 12 || y == 92 || y == 82))
			cout<< endl <<"Split";
		if (d == 8 && y == 102)
			cout<< endl <<"Stand";
		if (d == 8 && (y == 72 || y == 62 || y == 42))
			cout<< endl <<"Hit";
		if (d == 8 && y == 52)
			cout<< endl <<"Double";
		if (d == 9 && (y == 12 || y == 92 || y == 82))
			cout<< endl <<"Split";
		if (d == 9 && y == 102)
			cout<< endl <<"Stand";
		if (d == 9 && (y == 72 || y == 62 || y == 42))
			cout<< endl <<"Hit";
		if (d == 9 && y == 52)
			cout<< endl <<"Double";
		if (d == 10 && (y == 12 || y == 82))
			cout<< endl <<"Split";
		if (d == 10 && (y == 102 || y == 92))
			cout<< endl <<"Stand";
		if (d == 10 && (y == 72 || y == 62 || y == 52 || y == 42 || y == 32 || y == 22))
			cout<< endl <<"Hit";
		if (d == 1 && (y == 12 || y == 82))
			cout<< endl <<"Split";
		if (d == 1 && (y == 102 || y == 92))
			cout<< endl <<"Stand";
		if (d == 1 && (y == 72 || y == 62 || y == 52 || y == 42 || y == 32 || y == 22))
			cout<< endl <<"Hit";
    } 
}  while (1);
    return 0;
} 


Try this.
Last edited on
Thank you iseepluslus, there is one more problem with my code if i can trouble you with it, when the computer gives me the answer, and it returns to the begining, can I input a pause between the answer and the return?
If you on windows, and you want to pause for a specified amount of time, then you can use this.

1
2
#include <windows.h>
Sleep(enter an amount of time to pause for in milliseconds here);


Or you might add the other lines you had which I took out at the top. To wait for user input.
Topic archived. No new replies allowed.