Computer Science Canada longest word in a sentence |
Author: | scorpion1087 [ Thu Nov 06, 2003 1:10 pm ] |
Post subject: | longest word in a sentence |
i need to create a sentence an find the longest word in that sentence. if you could give me a hand i would be thankfull. this is my code so far var SENT : string put "enter a sentence" get SENT : * put "the total length is", length (SENT) for i : 1 .. length (SENT) if SENT (i) = "" then put SENT (i - 1) end if put "the number of spaces is", SENT (i-1) end for |
Author: | AsianSensation [ Thu Nov 06, 2003 2:54 pm ] | ||
Post subject: | |||
ok, well first you have to break down your sentence into words. run a for loop to break the sentence into words, and have a counter that keeps track of which one is the highest.
|
Author: | Andy [ Fri Nov 07, 2003 11:32 pm ] |
Post subject: | |
tsk tsk tsk asian, forgot index so soon? ![]() |
Author: | AsianSensation [ Sat Nov 08, 2003 4:33 pm ] |
Post subject: | |
index? what is this index you speak of? seriously though, I didn't even think about using index for this, but how is using index faster? |