Working With Arrays

Jan 12, 2012 at 11:49pm
Hi!
I've spent a great deal of time trying to figure out the issue in my program. It's attempting to determine the numerical property of a third card, with each row representing one card. The other "cards" are just junk in the 2d array right now.I'm getting an output of 2321, as opposed to the desired property of 2121.
Could anyone point me in the right direction?
Many thanks.
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
#include <iostream>
using namespace std;
int main ()
{
	int countera,counterb,counterc;
	int special [4];
	int temp;
	int cardstack[4][12]={2,3,1,2,
		2,2,3,3,
		2,3,1,2,
		3,2,1,2,
		2,3,2,1,
		3,2,1,1,
		2,2,2,2,
		1,1,1,1,
		2,3,1,2,
		1,3,2,1,
		2,3,3,1,
		3,3,3,3
	};
	for (int i=0;i<4;i++)
	{
		temp=cardstack[i][0]+cardstack[i][0];
			if (temp=3)
			{
				special[i]=3;
			}
			if (temp=4)
			{
				special[i]=2;
			}
			if (temp=5)
			{
				special[i]=1;
			}
			if (cardstack[i][1]=cardstack[i][0])
			{
				special[i]=cardstack[i][1];
			}
	}
	for (int b=0;b<4;b++)
	{
		cout <<special[b];
	}
	system ("pause");
	return 0;
}
Jan 13, 2012 at 2:57am
In if statement your are doing comparision in wrong way.You have to compare by '==' double equal sign.
Topic archived. No new replies allowed.