lesson 10 im not shure yet

This commit is contained in:
deck committed 2026-10-07 21:52:40 +02:00
1 parent cfb394d1bd
commit ec00465078
1 file changed
+16 -9
+16 -9
View File
@@ -1,16 +1,23 @@
#include <stdio.h> #include <stdio.h>
#include <stdnoreturn.h>
void swap(int *a, int *b) { typedef struct {
int temp = *a; int x, y;
*a = *b; } Point;
*b = temp;
/* 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 main(void) {
int a, b; int x1, y1, x2, y2;
scanf("%d %d", &a, &b); scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
swap(&a, &b);
printf("%d %d\n", a, b); 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; return 0;
} }