-
Notifications
You must be signed in to change notification settings - Fork 0
/
point.c
32 lines (26 loc) · 951 Bytes
/
point.c
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
/* * * * * * *
* Point data structure with x and y coordinate for Assignment 1
*
* created for COMP20007 Design of Algorithms 2019
* template by Tobias Edwards <[email protected]>
* implementation by <Tian Qiu 988121>
*/
// You must not change any of the code already provided in this file, such as
// type definitions, constants or functions.
//
// You may, however, add additional functions and/or types which you may need
// while implementing your algorithms and data structures.
#include <stdio.h>
#include "point.h"
// Returns a new Point (note, this is not a pointer to a Point)
// Since it's not allocated using dynamic memory allocation it does not
// need to be freed
Point new_point(double x, double y) {
Point point = {x, y};
return point;
}
// Prints (on its own line) the Point in the format "x y"
void print_point(Point p) {
printf("%.2f %.2f\n", p.x, p.y);
}
// TODO: Add any other functions you may need