operation on c++

hello guys...

i got confused on (not equal, !=) operation. i have this data

1 4 8 8
3 5 4 5
4 2 2 3
5 3 7 0

above there are 4 columns and 4 rows. my idea is, in my program, the second column will detect whether each number in this columns have the same value same first column or not, if NO then, it will return the second columns.. same goes to third column

so the result should be like this

1 4 4 5
3 5 3
4 3
5

this is my code

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
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;

int a1,maks,**q,**y,noofevamesh,**p;
void readdata1();
void readdata2();

void main()
{
	readdata1();
}

void readdata1()
{
	ifstream infile;
	infile.open("sengal.txt");

	if(infile.fail())
	{
		cout << " Fail " << endl;
	}

	infile >> a1;
	infile >> maks;


	
	q = new int *[a1];
	for(int i=0;i<a1;i++)
		q[i] = new int[4];

	for(int i=0;i<a1;i++)
	{
		infile >> q[i][0] >> q[i][1] >> q[i][2] >> q[i][3];
	}

	readdata2();
}

void readdata2()
{
	y = new int*[a1];
	for(int i=0;i<a1;i++)
		y[i] = new int[4];

	for(int i=0;i<a1;i=i+maks)
	{
		if(i < maks)
		{
			for(int j=0;j<maks-i;j++)
			{
				y[j][0] = q[j][0] ; y[j][1] = q[j][1]; y[j][2] = q[j][2];
				for(int k=i;k<maks-i;k++)
				{
					if(y[j][2] > -1 )
					{
						
						if(q[k][0] != y[j][2])
							cout << y[j][2] << endl;
					}
				}
			}
		}
	}


but if i put != this operation, then it will not return as what i want.
but if i put == this operation, then it will give the same value as first column which i don't want this to be happened.

i really hope anyone here can help me and tell me why this happened.

thank you so much...
Last edited on
but if i put != this operation, ...
but if i put == this operation,...


Put it where?
if i put != into this code..

if(y[j][2] > -1 )
{

if(q[k][0] != y[j][2])
cout << y[j][2] << endl;

}

Topic archived. No new replies allowed.