program TimTuDaiNhat;
var
str, maxWord: string;
i, start, len, maxLen: integer;
begin
writeln('Nhap vao mot xau ky tu:');
readln(str);
// Khoi tao gia tri ban dau
maxLen := 0;
start := 1;
len := 0;
i := 1;
// Duyet tung ky tu trong xau
while i <= length(str) do
begin
// Neu ky tu hien tai khac khoang trang, tang do dai cua tu len 1
if str[i] <> ' ' then
len := len + 1
else
begin
// Neu do dai cua tu hien tai lon hon do dai toi da truoc do, cap nhat gia tri maxLen va vi tri bat dau cua tu
if len > maxLen then
begin
maxLen := len;
start := i - len;
end;
len := 0;
end;
// Neu dang o ky tu cuoi cung cua xau, kiem tra do dai cua tu cuoi cung
if i = length(str) then
begin
if len > maxLen then
begin
maxLen := len;
start := i - len + 1;
end;
end;
i := i + 1;
end;
// Trich ra tu co do dai lon nhat tu xau
maxWord := copy(str, start, maxLen);
// In ra tu co do dai lon nhat
writeln('Tu co do dai lon nhat la: ', maxWord);
readln;
end.