data-structures · beginner · ~15 min
Declare a struct and access its members.
Define struct Point { int x, y; }; and implement int manhattan(struct Point a, struct Point b) returning |a.x-b.x| + |a.y-b.y|.
struct Point { int x, y; };
int manhattan(struct Point a, struct Point b) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.