mirror of
https://github.com/ada-dmitry/TMP_C712.git
synced 2026-09-24 09:10:16 +00:00
added new task
This commit is contained in:
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
float dist(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
float res, a, b;
|
||||
|
||||
a = abs(x1 - x2);
|
||||
b = abs(y1 - y2);
|
||||
res = sqrt(a * a + b * b);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
float area_geron(int x1, int y1, int x2, int y2, int x3, int y3)
|
||||
{
|
||||
float res, p, a, b, c;
|
||||
|
||||
a = dist(x1, y1, x2, y2);
|
||||
b = dist(x2, y2, x3, y3);
|
||||
c = dist(x1, y1, x3, y3);
|
||||
|
||||
p = (a + b + c) / 2;
|
||||
|
||||
res = sqrt(p * (p - a) * (p - b) * (p - c));
|
||||
|
||||
return res;
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
float dist(int x1, int y1, int x2, int y2);
|
||||
float area_geron(int x1, int y1, int x2, int y2, int x3, int y3);
|
||||
|
||||
int main()
|
||||
{
|
||||
int x1, y1, x2, y2, x3, y3; // координаты точек
|
||||
float len, area; // длина
|
||||
|
||||
scanf("%d%d", &x1, &y1); // прочитали числа
|
||||
scanf("%d%d", &x2, &y2);
|
||||
scanf("%d%d", &x3, &y3);
|
||||
|
||||
area = area_geron(x1, y1, x2, y2, x3, y3);
|
||||
|
||||
printf("%.3f\n", area);
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user