function max(a, b: integer): integer; begin if a > b then max := a else max := b; end;
begin readln(a, b); writeln(max(a, 2 * b) * max(2 * a - b, b)); end.
5) const n = 10;
var a: array[1..n] of integer; i, s: integer;
begin for i := 1 to n do begin readln(a[i]); if i mod 2 = 0 then s := s + a[i]; end; writeln(s); end.
6) const handsfree = false;
var a: array[1..100, 1..100] of real; product: real; i, j, m, n: integer;
begin {ввод матрицы} if handsfree then begin n := random(20) + 2; m := random(20) + 2; end else begin write('n, m ='); readln(n, m); end;
writeln('Данные матрицы:'); for i := 1 to m do begin for j := 1 to n do if handsfree then begin a[i, j] := random(100) - 50; write(a[i, j]:4, ' ') end else read(a[i, j]); writeln; end;
product := 1; for i := 1 to m do for j := 1 to n do if a[i, j] > 0 then product := product * a[i, j]; writeln('product = ', product); end.
zanthia94
17.02.2020
//Dev C++ 4.9.9.2
#include <iostream> #include <cmath> using namespace std;
int main(){ int x1,x2,x3,y1,y2,y3=0; double s,p,a,b,c,pp=0; cin>>x1>>y1>>x2>>y2>>x3>>y3; a=sqrt(pow(float(x2-x1),2)+pow(float(y2-y1),2)); b=sqrt(pow(float(x3-x2),2)+pow(float(y3-y2),2)); c=sqrt(pow(float(x3-x1),2)+pow(float(y3-y1),2)); p=a+b+c; pp=p/2; s=sqrt(pp*(pp-a)*(pp-b)*(pp-c)); cout<<"S="<<s<<endl; cout<<"P="<<p; cin.get(); cin.get(); return 0; }
Пример ввода: 1 1 1 5 6 7 Пример вывода: S=10 P=17.1954
var a,b,c,d,k:integer;
begin
k:=0;
writeln('Введите 4 числа');
readln(a,b,c,d);
if (a mod 7 = 0) and (a<>0) then k:=k+1;
if (b mod 7 = 0) and (b<>0) then k:=k+1;
if (c mod 7 = 0) and (c<>0) then k:=k+1;
if (d mod 7 = 0) and (d<>0) then k:=k+1;
writeln('Кол-во чисел кратных 7 = ', k);
end.
Объяснение: