Добавил:
lublyanka
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
#include <stdio.h>
#include <time.h>
#define _USE_MATH_DEFINES
#include <math.h>
int main()
{
float x1 = 0, y1 = 0, x2, y2 = 0, x3=0, y3 ; //coordinates rectangle
int p, q; // lenght of katets rectangle
float S;
FILE * f;
f=fopen("triangle.in","r");
fscanf(f,"%i %i ",&p, &q);
fclose(f);
f=fopen("triangle.out", "w");
//if (p < q)
// {
// h = p; a = q;
// }
// else
// {
// h = q; a = p;
// }
// the maximum square of a triangle in the rectangle is equal to half square of a rectangle
S = 0.5 * p * q;
x2 = p;
//x3 = p;
y3 = q;
fprintf(f, "%0.1f\n", S);
fprintf(f, "%0.6f %0.6f\n", x1, y1);
fprintf(f, "%0.6f %0.6f\n", x2, y2);
fprintf(f, "%0.6f %0.6f\n", x3, y3);
fclose(f);
}