Var s: string; a, b: integer; begin readln(s); if s[1] = 'x' then begin a := StrToInt(s[3]); b := StrToInt(s[5]); if s[2] = '-' then a := -a; writeln(b - a); end else if s[3] = 'x' then begin a := StrToInt(s[1]); b := StrToInt(s[5]); if s[2] = '-' then begin a := -a; b := -b; end; writeln(b - a); end else if s[5] = 'x' then begin a := StrToInt(s[1]); b := StrToInt(s[3]); if s[2] = '-' then b := -b; writeln(a + b); end end.
учтите что никакой защиты от дурака или неверного ввода
function colcifr(a: integer): integer; var s, k: string; i, j: integer; begin i := a; repeat str(i mod 10, k); i := i div 10; if (pos(k, s) = 0) then begin s := concat(s, k); inc(j); end; until (i = 0); colcifr := j; end;
function sum(i: integer): integer; var a, b: integer; begin a := i; repeat b := b + a mod 10; a := a div 10; until (a = 0); sum := b; end;
var i: integer;
begin for i := 1000 to 9999 do if (i mod 2 + i mod 7 + i mod 11 = 0) then if (colcifr(i) = 2) then if (sum(i) = 30) then writeln(i); end.
s: string;
a, b: integer;
begin
readln(s);
if s[1] = 'x' then begin
a := StrToInt(s[3]);
b := StrToInt(s[5]);
if s[2] = '-' then a := -a;
writeln(b - a);
end
else if s[3] = 'x' then begin
a := StrToInt(s[1]);
b := StrToInt(s[5]);
if s[2] = '-' then begin
a := -a;
b := -b;
end;
writeln(b - a);
end
else if s[5] = 'x' then begin
a := StrToInt(s[1]);
b := StrToInt(s[3]);
if s[2] = '-' then
b := -b;
writeln(a + b);
end
end.
учтите что никакой защиты от дурака или неверного ввода
var
s, k: string;
i, j: integer;
begin
i := a;
repeat
str(i mod 10, k);
i := i div 10;
if (pos(k, s) = 0) then
begin
s := concat(s, k);
inc(j);
end;
until (i = 0);
colcifr := j;
end;
function sum(i: integer): integer;
var
a, b: integer;
begin
a := i;
repeat
b := b + a mod 10;
a := a div 10;
until (a = 0);
sum := b;
end;
var
i: integer;
begin
for i := 1000 to 9999 do
if (i mod 2 + i mod 7 + i mod 11 = 0) then
if (colcifr(i) = 2) then
if (sum(i) = 30) then
writeln(i);
end.
8778