Answer T23
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int x, y;
} Point;
void printPoint( Point *p )
{
printf("(%d, %d) ", p->x, p->y );
}
typedef struct
{
int red, green, blue;
} Color;
void printColor( Color *c )
{
printf("%3d red, %3d grn, %3d blu", c->red, c->green, c->blue );
}
typedef struct
{
Point p0, p1, p2;
Color color;
} Triangle;
void printTriangle( Triangle *t )
{
printf("Points: ");
printPoint( &t->p0 ); printPoint( &t->p1 ); printPoint( &t->p2 );
printf("\tColor: ");
printColor( &t->color );
printf("\n");
}
int main ()
{
/* Declare a variable here */
Triangle tri;
/* Leave the following unchanged */
tri.p0.x = 15;
tri.p0.y = 15;
tri.p1.x = 85;
tri.p1.y = 110;
tri.p2.x = 50;
tri.p2.y = 50;
tri.color.red = 123;
tri.color.green = 50;
tri.color.blue = 150;
printTriangle( &tri );
}