Ini ADT nya:
typedef struct{
float x;
float y;
} Point;
typedef struct
{
Point Paw;
Point Pakh;
} Line;
Nah yang ini isi dari beberapa methodnya:
Point MakePoint(float x, float y)
{
Point P;
P.x = x;
P.y = y;
return P;
}
Line MakeLine (Point p1, Point p2)
{
Line L;
L.Paw = p1;
L.Pakh = p2;
return L;
}
void BacaLine(Line* L)
{
cout << "\nP1 untuk Paw\n";
cout << " input x1 = "; scanf("%f", &L->Paw.x);
cout << " input y1 = "; scanf("%f", &L->Paw.y);
cout << "\nP2 untuk Pakh\n";
cout << " input x1 = "; scanf("%f", &L->Pakh.x);
cout << " input y1 = "; scanf("%f", &L->Pakh.y);
}
void TulisLine(Line L)
{
Point p1, p2;
p1 = GetPaw(L);
p2 = GetPakh(L);
printf("P1(x,y) dan P2(x,y) = P1(%.f, %.f) dan P2(%.f, %.f)", p1.x, p1.y, p2.x, p2.y);
}
0 comments:
Post a Comment