Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help?? How to make Turing search for a given word??
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
cohen_ohyea




PostPosted: Wed Jan 07, 2004 8:35 pm   Post subject: Help?? How to make Turing search for a given word??

I have to do a project where the user must enter a sentence or series of sentences and then asks them to search for a word in the sentence or sentences. Then displays the sentence with how many times the word they searched for appears. I need serious help Crying or Very sad Any Ideas?????
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Wed Jan 07, 2004 10:48 pm   Post subject: (No subject)

use the index function, cut the part of the string you already searched, and then index again. Then index some more until you run out of stuff to index with.

OR

break the sentence into individual words, store all the values in an array and then search like that.
DanShadow




PostPosted: Fri Jan 09, 2004 3:11 pm   Post subject: (No subject)

Yeah, go for an array. Store each word in an array, then cross check in a for loop (1.. length of array), the have a counter that adds up by 1 when it finds the word its looking for.
code:

var words : array 1 .. 30 of string
locate (2, 1)
put "Enter a sentence or two: " ..
for i : 1 .. 30
    locate (1, 1)
    put 30 - i, " words left."
    get words (i)
end for
var counter : int := 0
var txt : string := ""
put "What word do you wish to search for: " ..
get txt
for i : 1 .. 30
    if txt = words (i) then
        counter := counter + 1
    end if
end for
cls
put "The word ", txt, " was typed ", counter, " times in the sentence(s)."
put ""
for i : 1 .. 30
    put words (i), " " ..
end for

Yeah I know its messy, but thats how its done.
McKenzie




PostPosted: Fri Jan 09, 2004 3:52 pm   Post subject: (No subject)

Listen to AZN,
Index is the way to go, watch out for the problem of finding words within words. e.g.
"I went to the store"
does not have the word "we" in it, but index will tell you it does.
DanShadow




PostPosted: Fri Jan 09, 2004 7:19 pm   Post subject: (No subject)

Yeah, you probably should listen to Asian Sensation...he is the genius in these matters. I just havent ever worked with Index...Ill have to do that.
Andy




PostPosted: Fri Jan 09, 2004 7:32 pm   Post subject: (No subject)

dan shadow... dont call ur self the array master juss cuz you dont know about linked lists... but then again its turing...
DanShadow




PostPosted: Fri Jan 09, 2004 7:59 pm   Post subject: (No subject)

No, no, no...im not really the master of the Array...just the master of the rare and forbidden Demon Array....nah. I just couldnt think of anything to go after Demon Array...so I just put Master.... 8)
Andy




PostPosted: Fri Jan 09, 2004 8:01 pm   Post subject: (No subject)

well learn about linked lists any ways...
Sponsor
Sponsor
Sponsor
sponsor
DanShadow




PostPosted: Fri Jan 09, 2004 8:17 pm   Post subject: (No subject)

Ok Dodge, I will...but where should I look, Tutorials or something? The Turing Help file doesnt inc lude linked lists...
Andy




PostPosted: Fri Jan 09, 2004 8:35 pm   Post subject: (No subject)

i'll write a tutorial one of these days, but y not ask the new turing mod?
McKenzie




PostPosted: Fri Jan 09, 2004 8:42 pm   Post subject: (No subject)

Don't worry Dan, Dodge just feels that you're stealing his schtick. Dodge his earned he Whatdotcolour warrior title, but he doesn't see any proof that you've earned yours.
As for advanced topics that people mention to make you feel small (and that was the only reason Dodge brought it up (be honest Dodge)). Use the Search feature provided in this site. If you find nothing try google. With google you will almost always get C/C++ help however (often if you read into it you will still glean the basic ideas)
Andy




PostPosted: Fri Jan 09, 2004 9:14 pm   Post subject: (No subject)

ok fine... mckenzie is rite, i was just being mean... dont take the stuff i say too seriously unless whatdotcolor is in it and noob is not used in the same sentence.
cohen_ohyea




PostPosted: Sun Jan 11, 2004 1:03 pm   Post subject: (No subject)

You guys have been very helpful but I am still kind of vauge of how the index function is used. Embarassed
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 13 Posts ]
Jump to:   


Style:  
Search: