Надо составить-блок схему
Значения переменных А, В, С поменять местами так, чтобы оказалось
А>=В>=С. Переменные А, В, С заданы.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
double a, b, c, max=0, min=0, sr=0;
Console.Write("Enter a: ");
a = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter b: ");
b = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter c: ");
c = Convert.ToDouble(Console.ReadLine());
if ((a > b) && (a > c) && (b > c))
{
max = a;
min = c;
sr = b;
}
if ((a > b) && (a > c) && (b < c))
{
max = a;
min = b;
sr = c;
}
if ((a < b) && (a < c) && (b > c))
{
max = b;
min = a;
sr = c;
}
if ((a < b) && (a > c) && (b > c))
{
max = b;
min = c;
sr = a;
}
if ((a < b) && (a < c) && (b < c))
{
max = c;
min = a;
sr = b;
}
if ((a > b) && (a < c) && (b < c))
{
max = c;
min = b;
sr = a;
}
a = max;
b = sr;
c = min;
}
}
}
CONST n = 10
DIM a(1 TO n) AS DOUBLE, b(1 TO n) AS DOUBLE, x(1 TO n) AS DOUBLE
RANDOMIZE TIMER
CLS
FOR i = 1 TO n
a(i) = 50 * RND - 25
b(i) = 50 * RND - 25
IF a(i) <> 0 THEN
x(i) = b(i) / a(i)
ELSE
x(i) = 0
END IF
PRINT USING "###."; a(i);
PRINT " * ";
PRINT USING "###."; x(i);
PRINT " = ";
PRINT USING "###."; b(i)
NEXT i
Тестовое решение:
-14.65854 * 0.53867 = -7.89606
-14.19729 * 1.08311 = -15.37722
-17.21156 * -0.07488 = 1.28888
16.17024 * -1.09750 = -17.74690
-13.80126 * -1.06180 = 14.65417
17.78583 * 0.83055 = 14.77207
-10.95534 * -1.58899 = 17.40791
-11.84992 * 1.66222 = -19.69714
-24.91831 * -0.95948 = 23.90864
-12.68757 * 0.84160 = -10.67785
/*Решение с обобщения формула Брахмагупты для произвольного четырехугольника. Функция perimeter(double x[], double y[]) возвращает значение периметра, функция area(double x[], double y[]) возвращает значение площади, пример использования и реализация приведены ниже. */
#include <iostream>
#include <math.h>
double perimeter(double x[], double y[]);
double area(double x[], double y[]);
int main()
{
double x[4], y[4];
std::cout << "Quadrangle ABCD\n";
for (auto i = 0; i < 4; i++)
{
std::cout << "Input coordinates of point " << char(i + 'A') << ": ";
std::cin >> x[i] >> y[i];
}
std::cout << perimeter(x, y) << " " << area(x, y);
return 0;
}
double perimeter(double x[], double y[])
{
double a[4], p = 0;
for (auto i = 0; i < 4; i++)
{
a[i] = sqrt((x[i]-x[(i + 1) % 4]) * (x[i]-x[(i + 1) % 4]) + (y[i]-y[(i + 1) % 4]) * (y[i]-y[(i + 1) % 4]));
p += a[i];
}
return p;
}
double area(double x[], double y[])
{
double a[4], p = 0, s = 1, d[2];
for (auto i = 0; i < 4; i++)
{
a[i] = sqrt((x[i]-x[(i + 1) % 4]) * (x[i]-x[(i + 1) % 4]) + (y[i]-y[(i + 1) % 4]) * (y[i]-y[(i + 1) % 4]));
p += a[i];
}
for (auto i = 0; i < 4; i++)
{
s *= (p / 2- a[i]);
}
for (auto i = 0; i < 2; i++)
{
d[i] = sqrt((x[i]-x[i + 2]) * (x[i]-x[i + 2]) + (y[i]-y[i + 2]) * (y[i]-y[i + 2]));
}
s -= (a[0] * a[2] + a[1] * a[3] + d[0] * d[1]) * (a[0] * a[2] + a[1] * a[3] - d[0] * d[1]) / 4;
s = sqrt(s);
return s;
}