Program Julia9696; uses crt; const n=10; m=8; var A:array[1..n,1..m] of integer; cur,up,right,down,left,qw,i,j:integer; begin; randomize; writeln(' Alphaeus ');writeln; writeln ('Програма пошуку всіх елементів масиву А[1..n, 1..m], що менші, ніж усі сусідні'); for i:=1 to n do begin for j:=1 to m do begin A[i,j]:=random(101)-50; write(A[i,j]:3, ' '); end; writeln; end; writeln; qw:=0; for i:=1 to n do for j:=1 to m do begin cur:= A[i,j]; up:=0; right:=0;down:=0;left:=0; if i>1 then begin if cur<A[i-1,j] then up:=1; end else up:=1; if i<n then begin if cur<A[i+1,j] then down:=1; end else down:=1; if j>1 then begin if cur<A[i,j-1] then left:=1; end else left:=1; if j<m then begin if cur<A[i,j+1] then right:=1; end else right:=1; if up+right+down+left=4 then begin qw:=qw+1; writeln('Елемент масиву À[',i,',',j,'], що рівний ',A[i,j]:3,', є меншим за своїх сусідів'); end; end; writeln('Всього таких елементів: ',qw); end.
var
s, s1, s2, s3, s4, tmp1, tmp2: string;
i, a, b, c, d, e, f: integer;
begin
Writeln('Введите строку: ');
Readln(s);
//
for var k := 1 to length(s) do
begin
if (s[k] = '(') then
begin
var j := k + 1;
while (s[j].IsDigit) do
begin
tmp1 := tmp1 + s[j];
j := j + 1;
end;
var ch := s[j];
j := j + 1;
while (s[j].IsDigit) do
begin
tmp2 := tmp2 + s[j];
j := j + 1;
end;
case ch of
'+': begin s := s.Remove(k - 1, j - k + 1); s := s.Insert(k - 1, inttostr(tmp1.ToInteger + tmp2.ToInteger)); end;
'-': begin s := s.Remove(k - 1, j - k + 1); s := s.Insert(k - 1, inttostr(tmp1.ToInteger - tmp2.ToInteger)); end;
'*': begin s := s.Remove(k - 1, j - k + 1); s := s.Insert(k - 1, inttostr(tmp1.ToInteger * tmp2.ToInteger)); end;
'/': begin s := s.Remove(k - 1, j - k + 1); s := s.Insert(k - 1, inttostr(tmp1.ToInteger div tmp2.ToInteger)); end;
end;
break;
end;
end;
//
for i := 1 to length(s) do
begin
if (s[i] = '+') or (s[i] = '-') or (s[i] = '*') or (s[i] = '/') then
begin
s1 := copy(s, 1, i - 1);
s2 := copy(s, i + 1, length(s));
c := i;
end;
end;
for i := 1 to length(s1) do
begin
if (s1[i] = '+') or (s1[i] = '-') or (s1[i] = '*') or (s1[i] = '/') then
begin
s3 := copy(s1, 1, i - 1);
s4 := copy(s1, i + 1, length(s1));
e := i;
end;
end;
Val(s3, a, d);
Val(s4, b, d);
Val(s2, f, d);
if (s[e] = '/') and (s[c] = '/') then Writeln((a div b) div f);
if (s[e] = '/') and (s[c] = '*') then Writeln((a div b) * f);
if (s[e] = '+') and (s[c] = '*') then Writeln(a + (b * f));
if (s[e] = '*') and (s[c] = '*') then Writeln(a * b * f);
if (s[e] = '+') and (s[c] = '/') then Writeln(a + (b div f));
if (s[e] = '*') and (s[c] = '+') then Writeln((a * b) + f);
if (s[e] = '/') and (s[c] = '+') then Writeln((a div b) + f);
if (s[e] = '*') and (s[c] = '/') then Writeln((a * b) div f);
if (s[e] = '+') and (s[c] = '+') then Writeln(a + b + f);
if (s[e] = '-') and (s[c] = '-') then Writeln(a - b - f);
if (s[e] = '+') and (s[c] = '-') then Writeln(a + b - f);
if (s[e] = '-') and (s[c] = '+') then Writeln(a - b + f);
if (s[e] = '*') and (s[c] = '-') then Writeln((a * b) - f);
if (s[e] = '/') and (s[c] = '-') then Writeln((a div b) - f);
if (s[e] = '-') and (s[c] = '*') then Writeln(a - (b * f));
if (s[e] = '-') and (s[c] = '/') then Writeln(a - (b div f));
end.
uses crt;
const
n=10;
m=8;
var
A:array[1..n,1..m] of integer;
cur,up,right,down,left,qw,i,j:integer;
begin;
randomize;
writeln(' Alphaeus ');writeln;
writeln ('Програма пошуку всіх елементів масиву А[1..n, 1..m], що менші, ніж усі сусідні');
for i:=1 to n do
begin
for j:=1 to m do
begin
A[i,j]:=random(101)-50;
write(A[i,j]:3, ' ');
end;
writeln;
end;
writeln;
qw:=0;
for i:=1 to n do
for j:=1 to m do
begin
cur:= A[i,j];
up:=0; right:=0;down:=0;left:=0;
if i>1 then
begin
if cur<A[i-1,j] then up:=1;
end
else up:=1;
if i<n then
begin
if cur<A[i+1,j] then down:=1;
end
else down:=1;
if j>1 then
begin
if cur<A[i,j-1] then left:=1;
end
else left:=1;
if j<m then
begin
if cur<A[i,j+1] then right:=1;
end
else right:=1;
if up+right+down+left=4 then
begin
qw:=qw+1;
writeln('Елемент масиву À[',i,',',j,'], що рівний ',A[i,j]:3,', є меншим за своїх сусідів');
end;
end;
writeln('Всього таких елементів: ',qw);
end.