Programme qui trouve le plus long mot dans une phrase
Bonjour,
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| program long;
uses wincrt;
var ch,ch1:string;
i,r:integer;
Begin
readln(ch);
for i:=1 to length(ch) do
if ch[i] = ' ' then
begin
ch1:=copy(ch,1,i);
delete(ch,1,i);
end;
write(ch1);
end. |
De l'aide SVP.
Programme pascal qui trouve le plus long mot dans une phrase
Bonjour
Ce programme marche à 100% :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| program long;
uses wincrt;
var ch,mg,ch1:string[100];
i,l:integer;
Begin
WriteLn('ecrire la phrase');
readln(ch);
l:=Length(ch);
mg:=' ';
for i:=1 to length(ch) do
Begin
if (ch[i]= ' ' )OR(i=l ) then
begin
ch1:=copy(ch,1,i-1);
Delete(ch,1,i);
End;
if Length(ch1)>Length(mg) Then
Begin
mg:=ch1;
end;
End;
WriteLn('le mot le plus grand est ',mg);
end. |