Program pr9; type mas = array[-10..10] of integer; const n = 5; var s, i:integer; a:mas; begin randomize; writeln('Номера четных отрицательных элементов:'); s := 0; for i := 1 to n do begin a[i] := random(1000) - 500;{Числа рандомизируются от -500 до 500} end; for i:=1 to n do begin write(a[i], ' '); end; for i:=1 to n do begin if (a[i] < 0) and (a[i] mod 2 = 0) then begin write(i, ' '); s := s + a[i]; end; end; writeln; writeln('Их сумма = ', s); end.
type mas = array[-10..10] of integer;
const n = 5;
var s, i:integer;
a:mas;
begin
randomize;
writeln('Номера четных отрицательных элементов:');
s := 0;
for i := 1 to n do
begin
a[i] := random(1000) - 500;{Числа рандомизируются от -500 до 500}
end;
for i:=1 to n do
begin
write(a[i], ' ');
end;
for i:=1 to n do
begin
if (a[i] < 0) and (a[i] mod 2 = 0)
then
begin
write(i, ' ');
s := s + a[i];
end;
end;
writeln;
writeln('Их сумма = ', s);
end.
function length(x1: real; y1: real; x2: real; y2: real): real;
begin
length := sqrt(sqr(x1 - x2) + sqr(y1 - y2));
end;
begin
read(x1, y1, x2, y2, x3, y3);
P := length(x1, y1, x2, y2) + length(x3, y3, x2, y2) + length(x1, y1, x3, y3);
writeln('Perimeter is ', P);
end.
#include <cmath>
#include <iostream>
float length(float x1, float y1, float x2, float y2)
{
return pow((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2), 0.5);
}
int main()
{
float x1, y1, x2, y2, x3, y3, P;
std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
P = length(x1, y1, x2, y2) + length(x3, y3, x2, y2) + length(x1, y1, x3, y3);
std::cout << "Perimeter is " << P;
}