
В B2 пиши =степень(A2;2)
В B3 пиши =степень(A3;2)
В С2 пиши =2*A2+9
В С3 пиши =2*A3+9
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.
1) x = -10, y1 = 100, y2 = -11
2) x = -9, y1 = 81, y2 = -9
3) x = -8, y1 = 64, y2 = -7
4) x = -7, y1 = 49, y2 = -5
5) x = -6, y1 = 36, y2 = -3
6) x = -5, y1 = 25, y2 = -1
7) x = -4, y1 = 16, y2 = 1
8) x = -3, y1 = 9, y2 = 3
9) x = -2, y1 = 4, y2 = 5
10) x = -1, y1 = 1, y2 = 7
11) x = 0, y1 = 0, y2 = 9
12) x = 1, y1 = 1, y2 = 11
13) x = 2, y1 = 4, y2 = 13
14) x = 3, y1 = 9, y2 = 15
15) x = 4, y1 = 16, y2 = 17
16) x = 5, y1 = 25, y2 = 19
17) x = 6, y1 = 36, y2 = 21
18) x = 7, y1 = 49, y2 = 23
19) x = 8, y1 = 64, y2 = 25
20) x = 9, y1 = 81, y2 = 27
21) x = 10, y1 = 100, y2 = 29
22) x = 11, y1 = 121, y2 = 31
Объяснение:
Программа написана на DevC++.