Объяснение:
1
program Middle;
var
mid, x1,x2,x3 : integer;
begin
write('input x1, x2, x3 ');
readln(x1,x2,x3);
if x1 < x2
then if x1 < x3
then if x2 < x3
then mid := x2
else mid := x3
else mid := x1
else if x1 > x3
then if x2 < x3
then mid := x3
else mid := x2
else mid := x1;
writeln ('Middle is ',mid);
end.
2
program pifagor;
var
Cat1, Cat2, Hyp, Space : real;
begin
write ('Cat1, Cat2 :');
Readln (Cat1, Cat2);
Hyp := sqrt (sqr(Cat1)+sqr(Cat2));
Space := (Cat1 * Cat2)/2;
WriteLn ('By Cat1 =',Cat1:5:2,' and Cat2 = ',Cat2:5:2,' Hyp is: ',Hyp:5:2, ' Space is: ',Space:5:2);
end.
#include <iomanip>
int main()
{
using namespace std;
const int N = 4;
const int M = 4;
int Y[N][M];
//как-нибудь заполняем матрицу
for (int i = 0; i < N; ++i)
for (int j = 0; j < M; ++j)
Y[i][j] = (i + 1) * (j + 1);
//выведем её на экран
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < M; ++j)
cout << setw(3) << Y[i][j];
cout << endl;
}
//находим сумму элементов побочной диагонали
int S = 0;
for (int i = 0; i < N; ++i)
for (int j = 0; j < M; ++j)
if (j == M - 1 - i)
S = S + Y[i][j];
cout << "Sum of adverse diagonal of array: " << S << endl;
//находим сумму всех элементов матрицы
int Sum = 0;
for (int i = 0; i < N; ++i)
for (int j = 0; j < M; ++j)
Sum = Sum + Y[i][j];
cout << "Sum of all elements of array: " << Sum << endl;
return 0;
}