Created
April 5, 2013 15:05
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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