mirror of
https://github.com/nolongeractivemp3/shipthatcode-c.git
synced 2026-11-24 10:45:12 +01:00
lesson 10 im not shure yet
This commit is contained in:
1 parent
cfb394d1bd
commit
ec00465078
1 file changed
+16
-9
@@ -1,16 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <stdnoreturn.h>
|
||||
|
||||
void swap(int *a, int *b) {
|
||||
int temp = *a;
|
||||
*a = *b;
|
||||
*b = temp;
|
||||
typedef struct {
|
||||
int x, y;
|
||||
} Point;
|
||||
|
||||
/* TODO: return the squared distance between a and b. */
|
||||
int dist2(Point a, Point b) {
|
||||
int result = ((b.x - a.x) * (b.x - a.x)) + ((b.y - a.y) * (b.y - a.y));
|
||||
return result;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int a, b;
|
||||
scanf("%d %d", &a, &b);
|
||||
swap(&a, &b);
|
||||
printf("%d %d\n", a, b);
|
||||
int x1, y1, x2, y2;
|
||||
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
|
||||
|
||||
Point a = {x1, y1};
|
||||
Point b = {y2, x2};
|
||||
/* TODO: build a from (x1, y1) and b from (x2, y2). */
|
||||
|
||||
printf("%d\n", dist2(a, b));
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user