Skip to content

Instantly share code, notes, and snippets.

@tuankiet65
Last active December 15, 2015 19:10
Show Gist options
  • Save tuankiet65/5309617 to your computer and use it in GitHub Desktop.
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
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