Skip to content

Instantly share code, notes, and snippets.

@tuankiet65
Created April 5, 2013 15:05
Show Gist options
  • Save tuankiet65/5320003 to your computer and use it in GitHub Desktop.
Save tuankiet65/5320003 to your computer and use it in GitHub Desktop.
Nhập vào 5 số, thêm dấu '+' hay '-' để có phép tính với tổng lớn nhất
program max_tong;
uses crt;
var s, tmp: string;
i: byte;
input: int64;
begin
clrscr;
for i:=1 to 5 do begin
write('Nhap so thu ', i, ': ');
readln(input);
str(input, tmp);
if input>=0 then begin
if i=5 then s:=s+tmp else s:=s+tmp+'+';
end else begin
if s[length(s)]='+' then delete(s, length(s), 1);
tmp:='-'+'('+tmp+')';
s:=s+tmp;
end;
end;
write(s);
readkey;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment