Const N = 13; Var A:array[1..N] of integer; i,j:integer; Begin For i:= 1 to N do Begin A[i]:=random(21)-10; Write(A[i],' '); End; WriteLn; For j:= 1 to N do For i:= 1 to N-1 do if A[i]<A[i+1] then Swap(A[i],A[i+1]); For i:= 1 to N do Write(A[i],' ');
End.
2)
Var A:array[1..4,1..4] of integer; i,j:integer; Begin For i:= 1 to 4 do Begin For j:= 1 to 4 do Begin if (i+j) mod 2 = 0 then A[i,j]:=i*j else A[i,j]:=i+j; Write(A[i,j],' ') End; WriteLn End; End.
using System;
class Program
{
static void Main()
{
int x1 = 2, y1 = 1;
int x2 = 6, y2 = 5;
int x3 = 10, y3 = 1;
var a = Distance(x2, y2, x3, y3);
var b = Distance(x1, y1, x3, y3);
var c = Distance(x2, y2, x1, y1);
Console.WriteLine("S = {0}", Square(a, b, c));
Console.ReadKey();
}
//растояние между точками
static double Distance(int x1, int y1, int x2, int y2)
{
return Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
//формула герона
static double Square(double a, double b, double c)
{
var p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
// теорема косинусов
static double Angle(double a, double b, double c)
{
return Math.Acos((b * b + c * c - a * a) / (2 * b * c));
}
static bool IsAcuteAngel(double alpha)
{
return alpha < Math.PI / 2;
}
}
Const
N = 13;
Var
A:array[1..N] of integer;
i,j:integer;
Begin
For i:= 1 to N do
Begin
A[i]:=random(21)-10;
Write(A[i],' ');
End;
WriteLn;
For j:= 1 to N do
For i:= 1 to N-1 do
if A[i]<A[i+1] then Swap(A[i],A[i+1]);
For i:= 1 to N do
Write(A[i],' ');
End.
2)
Var
A:array[1..4,1..4] of integer;
i,j:integer;
Begin
For i:= 1 to 4 do
Begin
For j:= 1 to 4 do
Begin
if (i+j) mod 2 = 0 then A[i,j]:=i*j
else A[i,j]:=i+j;
Write(A[i,j],' ')
End;
WriteLn
End;
End.