Quite a long time ago at the school competition there was a task (a little lower), I could not write it in pascal , but I easily dealt with it in php . But all the same it is interesting how the decision on pascal e would look
Here is the task itself:
A simple declarative sentence is entered (words are separated by a space). Display the word of the greatest length. The program should: a) accept the original sentence from the keyboard b) display the word of the greatest length
Here is my solution on php
$item = $_POST["item"];//введенное предложение $array = explode(" ",$item); $max["length"] = 0; $max["word"] = ""; for($i=0;$i < count($array);$i++) { if(strlen($array[$i]) > $max["length"]) { $max["word"] = $array[$i]; $max["length"] = strlen($array[$i]); } } echo "Первое самое длинное слово: <b>".$max["word"]."[".$max["length"]."]</b>"; }