using namespace std;
struct Treugolnik
{
int x1, y1;
int x2, y2;
int x3, y3;
};
int main()
{
Treugolnik a1;
cin >> a1.x1;
cin >> a1.x2;
cin >> a1.x3;
cin >> a1.y1;
cin >> a1.y2;
cin >> a1.y3;
float S, P, h,p;
P = sqrt(pow(a1.x2 - a1.x1, 2) + pow(a1.y2 - a1.y1, 2))+sqrt(pow(a1.x3 - a1.x2, 2) + pow(a1.y3 - a1.y2, 2))+ sqrt(pow(a1.x3 - a1.x1, 2) + pow(a1.y3 - a1.y1, 2));
p = 0.5*(sqrt(pow(a1.x2 - a1.x1, 2) + pow(a1.y2 - a1.y1, 2)) + sqrt(pow(a1.x3 - a1.x2, 2) + pow(a1.y3 - a1.y2, 2)) + sqrt(pow(a1.x3 - a1.x1, 2) + pow(a1.y3 - a1.y1, 2)));
S = sqrt(p*(p - sqrt(pow(a1.x2 - a1.x1, 2) + pow(a1.y2 - a1.y1, 2*(p - sqrt(pow(a1.x3 - a1.x2, 2) + pow(a1.y3 - a1.y2, 2)))*(p - sqrt(pow(a1.x3 - a1.x1, 2) + pow(a1.y3 - a1.y1, 2)));
h = 2 * S / sqrt(pow(a1.x2 - a1.x1, 2) + pow(a1.y2 - a1.y1, 2)); только к одной стороне
if (sqrt(pow(a1.x2 - a1.x1, 2) + pow(a1.y2 - a1.y1, 2)) == sqrt(pow(a1.x3 - a1.x2, 2) + pow(a1.y3 - a1.y2, 2)) == sqrt(pow(a1.x3 - a1.x1, 2) + pow(a1.y3 - a1.y1, 2)))
cout << "ранвостронний";
if (pow(sqrt(pow(a1.x2 - a1.x1, 2) + pow(a1.y2 - a1.y1, 2)), 2)+pow(sqrt(pow(a1.x3 - a1.x2, 2) + pow(a1.y3 - a1.y2, 2)),2)==pow(sqrt(pow(a1.x3 - a1.x1, 2) + pow(a1.y3 - a1.y1, 2)),2));
cout << "прямоугольный";
cout << S;
cout << h;
cout << P;
return 0;
}
1. Среднее арифметическое.
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int num; float arithm = 0, count = 0, sum = 0;
cout << "Enter numbers (0 - a sign of the end of input) : " << endl;
do
{
cin >> num;
if (num != 0)
{
count++;
sum += num;
}
} while (num != 0);
arithm = sum / count;
if (sum == 0) cout << "Error." << endl; else
cout << "The arithmetic mean of these numbers = " << arithm << endl;
system ("pause");
return 0;
}
2. Максимальный элемент последовательности.
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int num; float max = INT_MIN, count = 0, sum = 0;
cout << "Enter numbers (0 - a sign of the end of input) : " << endl;
do
{
cin >> num;
if (num != 0)
{
if (num > max) max = num;
}
} while (num != 0);
if (max == INT_MIN) cout << "Error." << endl; else
cout << "Maximum element: = " << max << endl;
system ("pause");
return 0;
}
begin
write('n = '); readln(n);
while n>99 do n:=n div 10;
k1:=n div 10;
k2:=n mod 10;
writeln('1 цифра = ',k1,' 2 цифра = ',k2);
if k1 mod 2 = 0
then writeln('1-я цифра четная')
else writeln('1-я цифра нечетная');end.
Пример:
n = 5632149
1 цифра = 5 2 цифра = 6
1-я цифра нечетная