{$mode Delphi}
type PolynomBuilder = class
private
polynom : string;
procedure Append( member : integer );
procedure Append( multiplicant : integer; variable : string ); overload;
public
function Get:string;
end;
procedure PolynomBuilder.Append( member : integer );
var memberStr : string;
begin
if
member <> 0
then begin
str( member, memberStr );
if
polynom = ''
then
polynom := memberStr
else begin
if
member < 0
then
polynom := polynom + memberStr
else
polynom := polynom + '+' + memberStr;
end;
end;
end;
procedure PolynomBuilder.Append( multiplicant : integer; variable : string ); overload;
var multiplicantStr, member : string;
begin
if
multiplicant <> 0
then begin
if
abs(multiplicant) <> 1
then
str( multiplicant, multiplicantStr )
else if
multiplicant = -1
then
multiplicantStr := '-';
member := multiplicantStr + variable;
if
polynom = ''
then
polynom := member
else begin
if
multiplicant < 0
then
polynom := polynom + member
else
polynom := polynom + '+' + member;
end;
end;
end;
function PolynomBuilder.Get : string;
begin
Get := polynom;
end;
var Polynom : PolynomBuilder;
a, b, c, i: integer;
begin
for i:=1 to 5 do begin
Polynom := PolynomBuilder.Create;
readln(a, b, c);
Polynom.Append(a);
Polynom.Append(b, 'x');
Polynom.Append(c, 'y');
writeln( Polynom.Get );
Polynom.Free;
end;
end.
eyRtb2RlIERlbHBoaX0KCnR5cGUgUG9seW5vbUJ1aWxkZXIgPSBjbGFzcwoJcHJpdmF0ZQoJCXBvbHlub20gOiBzdHJpbmc7CgkJcHJvY2VkdXJlIEFwcGVuZCggbWVtYmVyIDogaW50ZWdlciApOwoJCXByb2NlZHVyZSBBcHBlbmQoIG11bHRpcGxpY2FudCA6IGludGVnZXI7IHZhcmlhYmxlIDogc3RyaW5nICk7IG92ZXJsb2FkOwoKCXB1YmxpYwoJCWZ1bmN0aW9uIEdldDpzdHJpbmc7CgkJCgllbmQ7CgoKcHJvY2VkdXJlIFBvbHlub21CdWlsZGVyLkFwcGVuZCggbWVtYmVyIDogaW50ZWdlciApOwp2YXIgbWVtYmVyU3RyIDogc3RyaW5nOwpiZWdpbgoJaWYgCgkJbWVtYmVyIDw+IDAgCgl0aG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