C++ issue

11/03/2012 08:34 audreyxp2012#16
can you help me please i got this code how will i convert this. given an address and offset i got this in cheat engine table. what is the meaning of 7D4 2B0 3C8
<Address>A9B820</Address>
<Offset>7D4</Offset>
<Offset>2B0</Offset>
<Offset>3C8</Offset>
11/06/2012 16:18 ginneg#17
i think you cant do it from there
11/09/2012 14:05 o0Zero0o1#18
Seems the definition is a whole other story

Each point of the triangle is made up of two dots
Point A = x1,y1
Point B= x2,y2
Point C= x3,y3
like this on the pic:
[Only registered and activated users can see links. Click Here To Register...]

Calculating the distance between these points is like:
[Only registered and activated users can see links. Click Here To Register...]
Than finding S and P.


Now anyway when the program exe starts it should look like
Quote:
Number of Triangle you need to find S and P:
Insert data for point A
x=
y=
Insert data for point B
x=
y=
Insert data for point C
x=
y=
S= ... P =.... lala
So i need 3 values for X .... how am i going keep them separate while in structures.
11/09/2012 15:37 .SkyneT.#19
Quote:
Originally Posted by o0Zero0o1 View Post
Seems the definition is a whole other story

Each point of the triangle is made up of two dots
Point A = x1,y1
Point B= x2,y2
Point C= x3,y3
like this on the pic:
[Only registered and activated users can see links. Click Here To Register...]

Calculating the distance between these points is like:
[Only registered and activated users can see links. Click Here To Register...]
Than finding S and P.


Now anyway when the program exe starts it should look like


So i need 3 values for X .... how am i going keep them separate while in structures.
Code:
struct _Coordinate
{
     float x;
     float y;
};

int main()
{
	_Coordinate 
		A = {0.0, 0.0}, 
		B = {0.0, 0.0}, 
		C = {0.0, 0.0}; //Declare and initalize 3 "points" 

	std::cout << "Point A:" << std::endl << "X = ";
	std::cin >> A.x; //save input to x coordinate of A
	std::cout << "Y = ";
	std::cin >> A.y; //save input to y coordinate of A

	std::cout << "X1 = " << A.x << std::endl
		  << "Y1 = " << A.y << std::endl;

	return 0;
}
11/10/2012 15:05 o0Zero0o1#20
I have to use structures for both point and triangle so ....it has to be somehting like

Code:
#include<iostream.h>
#include<math.h>

struct Coordinate
{
float x;
float y;
};
struct Triangle
{
Point A;
Point B;
Point C;
};
int main{
cout<<"Point A \n x="
cin>> coordinate.x;
cout<<"Point A\n y="
cin>> coordinate.y;
cout<<"Point B \n x="
cin>> coordinate.x;
cout<<"Point B\n y="
cin>> coordinate.y;
cout<<"Point C \n x="
cin>> coordinate.x;
cout<<"Point C\n y="
cin>> coordinate.y;
Triangle.PointA = {coordinate.x , coordinate.y} // the ones we input for A
Triangle.PointB = {coordinate.x , coordinate.y} // for b ....
Triangle.PointC = {coordinate.x , coordinate.y} // for c .... 
---->// But how will the structures get 3 valeus for X and 3 for Y , won't it just over write them?

Side A = [img]http://img355.imageshack.us/img355/4259/image008yk1.jpg[/img]
//so on for the rest 2 sides

P = Side A + Side B + Side C
p = P/2
S = p //// heron's formula

cout<<"P=" <<P;
Cout<<"S="<< S;
return 0;
}
Something like this ... but it just wont work .... also need to input cycle with FOR for 'N' triangles ( N - unknown number that is being input upon program execution)
11/10/2012 19:10 .SkyneT.#21
Code:
struct _Coordinate
{
   float x;
   float y;
};

struct Triangle
{
   _Coordinate A;
   _Coordinate B;
   _Coordinate C;
};

int main()
{
   Triangle triangle = 
   {
      0.0, 0.0, //Ax, Ay
      0.0, 1.0, //Bx, By
      0.0, 0.0  //Cx, Cy
   };
}
Thats how to declare and initalize.
You can access every Value with "triangle.Point.Coordinate".
e.g: triangle.B.y //would be 1.0 here

To let the user put in 'n' triangles, just make a loop.
(this shouldn't be a problem or ? ;) )

Btw: To calculate a sqare root just use "sqrt()".
11/11/2012 08:27 o0Zero0o1#22
The coffe is heating up ... let's see what am i going to do :(

Code:
#include<iostream.h>
#include<math.h>
struct _Coordinate
{
   float x;
   float y;
};

struct Triangle
{
   _Coordinate A;
   _Coordinate B;
   _Coordinate C;
};

int main()
{
	int K,i;
	float S,P,p,Side_A,Side_B,Side_C;

	cout<<"Number of Triangles = " ;
	cin>>K;
	for (i=0;i<K;i++)
	{
        cout<<"Coordinates regarding A="<<endl << "X = ";
			cin>>Triangle.A.x;
		cout<<"Coordinates regarding A="<<endl << "Y = ";
			cin>>Triangle.A.y;
		cout<<"Coordinates regarding B="<<endl << "X = ";
			cin>>Triangle.B.x;
		cout<<"Coordinates regarding B="<<endl << "Y = ";
			cin>>Triangle.B.y;
		cout<<"Coordinates regarding B="<<endl << "X = ";
			cin>>Triangle.C.x;
		cout<<"Coordinates regarding C="<<endl << "Y = ";
			cin>>Triangle.C.y;
		Side_A = sqrt( (Triangle.C.x*Triangle.C.x)-(2*Triangle.B.x*Triangle.C.x)+(Triangle.B.x*Triangle.B.x)+(Triangle.C.y*Triangle.C.y)-(2*Triangle.B.y*Triangle.C.y)+(Triangle.B.y*Triangle.B.y));
		Side_B = sqrt( (Triangle.A.x*Triangle.A.x)-(2*Triangle.C.x*Triangle.A.x)+(Triangle.C.x*Triangle.C.x)+(Triangle.A.y*Triangle.A.y)-(2*Triangle.C.y*Triangle.A.y)+(Triangle.C.y*Triangle.C.y));
		Side_C = sqrt( (Triangle.B.x*Triangle.B.x)-(2*Triangle.B.x*Triangle.A.x)+(Triangle.A.x*Triangle.A.x)+(Triangle.B.y*Triangle.B.y)-(2*Triangle.A.y*Triangle.B.y)+(Triangle.A.y*Triangle.A.y));
	
	
	P = Side_A+Side_B+Side_C; //perimeter
	p = P/2; //semiperimeter needed for the Heron's formula
	S = sqrt(p(p-Side_A)(p-Side_B)(p-Side_C) ); //Heron's formula for finding the area

	cout<<"\n The perimeter is = " <<P;
	cout<<"\n The are is = " <<S;
	cout<<endl;
	}
	return 0;
	
	
	
}

Cool ... it's like 19errors in the Visual C++ ... can't even understand the errors : |.The loop will work it is just that i have no idea how for example to put the outgoing data regarding each triangle , like :
Number of triangles: 7
..... data inpuiting ....
...calculations .....
output:
Triangle
1 ....
2....
3...
11/11/2012 14:52 .SkyneT.#23
Quote:
Originally Posted by o0Zero0o1 View Post
The coffe is heating up ... let's see what am i going to do :(

Code:
#include<iostream.h>
#include<math.h>
struct _Coordinate
{
   float x;
   float y;
};

struct Triangle
{
   _Coordinate A;
   _Coordinate B;
   _Coordinate C;
};

int main()
{
	int K,i;
	float S,P,p,Side_A,Side_B,Side_C;

	cout<<"Number of Triangles = " ;
	cin>>K;
	for (i=0;i<K;i++)
	{
        cout<<"Coordinates regarding A="<<endl << "X = ";
			cin>>Triangle.A.x;
		cout<<"Coordinates regarding A="<<endl << "Y = ";
			cin>>Triangle.A.y;
		cout<<"Coordinates regarding B="<<endl << "X = ";
			cin>>Triangle.B.x;
		cout<<"Coordinates regarding B="<<endl << "Y = ";
			cin>>Triangle.B.y;
		cout<<"Coordinates regarding B="<<endl << "X = ";
			cin>>Triangle.C.x;
		cout<<"Coordinates regarding C="<<endl << "Y = ";
			cin>>Triangle.C.y;
		Side_A = sqrt( (Triangle.C.x*Triangle.C.x)-(2*Triangle.B.x*Triangle.C.x)+(Triangle.B.x*Triangle.B.x)+(Triangle.C.y*Triangle.C.y)-(2*Triangle.B.y*Triangle.C.y)+(Triangle.B.y*Triangle.B.y));
		Side_B = sqrt( (Triangle.A.x*Triangle.A.x)-(2*Triangle.C.x*Triangle.A.x)+(Triangle.C.x*Triangle.C.x)+(Triangle.A.y*Triangle.A.y)-(2*Triangle.C.y*Triangle.A.y)+(Triangle.C.y*Triangle.C.y));
		Side_C = sqrt( (Triangle.B.x*Triangle.B.x)-(2*Triangle.B.x*Triangle.A.x)+(Triangle.A.x*Triangle.A.x)+(Triangle.B.y*Triangle.B.y)-(2*Triangle.A.y*Triangle.B.y)+(Triangle.A.y*Triangle.A.y));
	
	
	P = Side_A+Side_B+Side_C; //perimeter
	p = P/2; //semiperimeter needed for the Heron's formula
	S = sqrt(p(p-Side_A)(p-Side_B)(p-Side_C) ); //Heron's formula for finding the area

	cout<<"\n The perimeter is = " <<P;
	cout<<"\n The are is = " <<S;
	cout<<endl;
	}
	return 0;
	
	
	
}

Cool ... it's like 19errors in the Visual C++ ... can't even understand the errors : |.The loop will work it is just that i have no idea how for example to put the outgoing data regarding each triangle , like :
Number of triangles: 7
..... data inpuiting ....
...calculations .....
output:
Triangle
1 ....
2....
3...
Ok i should repeat it a little bit different:
"you HAVE TO declare and initalize the stuff"

Just use the struct like int or float.
Code:
   Triangle nomatterwhatnamethishas = 
   {
      0.0, 0.0, //Ax, Ay
      0.0, 0.0, //Bx, By
      0.0, 0.0  //Cx, Cy
   };
Then you access like that:
Code:
nomatterwhatnamethishas.A.x
Or save a value:
Code:
nomatterwhatnamethishas.A.x = 10
Or use cin:
Code:
std::cin >> nomatterwhatnamethishas.A.x
But this all will only work if you declared "nomatterwhatnamethishas" before.
Without declaration and using Triangle.A.x, it will never work!
11/11/2012 15:57 o0Zero0o1#24
Retard here <

And yes it actually work and i just got this now:
Code:
#include<iostream.h>
#include<math.h>
struct _Coordinate
{
   float x;
   float y;
};

struct _Triangle
{
   _Coordinate A;
   _Coordinate B;
   _Coordinate C;
};

int main()
{
	_Triangle Triangle ;
	int K,i;
	float S,P,p,Side_A,Side_B,Side_C;

	cout<<"Number of Triangles = " ;
	cin>>K;
	for (i=0;i<K;i++)
	{
        cout<<"Coordinates regarding A="<<endl << "X = ";
			cin>>Triangle.A.x;
		cout<<"Coordinates regarding A="<<endl << "Y = ";
			cin>>Triangle.A.y;
		cout<<"Coordinates regarding B="<<endl << "X = ";
			cin>>Triangle.B.x;
		cout<<"Coordinates regarding B="<<endl << "Y = ";
			cin>>Triangle.B.y;
		cout<<"Coordinates regarding B="<<endl << "X = ";
			cin>>Triangle.C.x;
		cout<<"Coordinates regarding C="<<endl << "Y = ";
			cin>>Triangle.C.y;
		Side_A = sqrt((Triangle.C.x*Triangle.C.x)-(2*Triangle.B.x*Triangle.C.x)+(Triangle.B.x*Triangle.B.x)+(Triangle.C.y*Triangle.C.y)-(2*Triangle.B.y*Triangle.C.y)+(Triangle.B.y*Triangle.B.y));
		Side_B = sqrt((Triangle.A.x*Triangle.A.x)-(2*Triangle.C.x*Triangle.A.x)+(Triangle.C.x*Triangle.C.x)+(Triangle.A.y*Triangle.A.y)-(2*Triangle.C.y*Triangle.A.y)+(Triangle.C.y*Triangle.C.y));
		Side_C = sqrt((Triangle.B.x*Triangle.B.x)-(2*Triangle.B.x*Triangle.A.x)+(Triangle.A.x*Triangle.A.x)+(Triangle.B.y*Triangle.B.y)-(2*Triangle.A.y*Triangle.B.y)+(Triangle.A.y*Triangle.A.y));
	
	
	P = Side_A+Side_B+Side_C; 
	p = P/2; 
	S=sqrt(p*(p-Side_A)*(p-Side_B)*(p-Side_C));

	cout<<"\n The perimeter of triangle ["<<i<<"] = " <<P;
	cout<<"\n The are of triangle ["<<i<<"] = " <<S;
	cout<<endl;
	};
	return 0;
	
	
	
}

--------------------Configuration: dasda - Win32 Debug--------------------
Compiling...
aaaaaa.cpp
d:\program files\microsoft visual studio\myprojects\dasda\aaaaaa.cpp(38) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
d:\program files\microsoft visual studio\myprojects\dasda\aaaaaa.cpp(39) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
d:\program files\microsoft visual studio\myprojects\dasda\aaaaaa.cpp(40) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
d:\program files\microsoft visual studio\myprojects\dasda\aaaaaa.cpp(45) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data

aaaaaa.obj - 0 error(s), 4 warning(s)
It works just no clue how come this conversions form double to float?I didn't set anything to double,unless these were by default?

EDIT: Switched variables type to double , all cool ... 0/0
11/16/2012 13:58 o0Zero0o1#25
Now my teach said i'm on the right way it's just that i need to use massive ... all he gave me as hint was ... you will access the structures through the massive like

struct trio[N]
or trio[N].A.x
trio[N].A.y
.... so on .... any idea on that? -_-
11/23/2012 17:23 o0Zero0o1#26
One more question (bumping this thread to avoid starting new one)

Do you know the way to convert a C++ code into flowchart diagram in Microsoft Visio?