Last active
December 15, 2015 19:10
-
-
Save tuankiet65/5309617 to your computer and use it in GitHub Desktop.
Nhập 1 xâu, xác định từ có độ dài 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 longest_word; | |
uses crt; | |
var s, tmp, maxstring: ansistring; | |
i, maxlength: longint; | |
begin | |
clrscr; | |
write('Nhap xau: '); | |
readln(s); | |
while s<>'' do begin | |
if pos(' ', s)<>0 then begin | |
tmp:=copy(s, 1, (pos(' ', s)-1)); | |
delete(s, 1, pos(' ', s)); | |
if length(tmp)>maxlength then begin | |
maxlength:=length(tmp); | |
maxstring:=tmp; | |
end; | |
end else begin | |
if length(s)>maxlength then begin | |
maxlength:=length(s); | |
maxstring:=s; | |
end; | |
s:=''; | |
end; | |
end; | |
writeln('Tu lon nhat: ', maxstring); | |
write('Do dai: ', maxlength); | |
readkey; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment