| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Two assignment problems.. have to submit tomorrow.. please help..
1. Write a program tht will read in a text from a file , replace all occurance of the string |"and" by "or|" . write the modified text onto another file 2. write a program to search for a given word in a dictionary . the dictionary is a lexicographically sorted array as character strings. Use binary search method. |
|
#2
|
|||
|
|||
|
What do you need help with? You'll need to be a bit more specific than just posting your assignment sheet up and hoping someone will do it for you
![]() -KM- |
|
#3
|
|||
|
|||
|
Hey Mate!. Here's the thing.
1) First of all, if you want to keep it simple, use two pointers (one for each file). As you move throught the text, if the character is not an "A", just copy it to the new file. If the char is an "A", copy it to a Buffer and move on. If doing so, you spell "AND", empty the buffer and write OR on the new file. That is the simplest way to go. You can get both files as parameters with argc and argvec 2) You have to know from advance the binary search method. The procedure is simple (if I understand correctly). while start < finish { Pos = (start + finish) / 2} Check out the value > 0 part, for I don't recall the returned values of strcmp correctly. But the escential idea is that. Hope it works!! Anibal. PS: Grab a damn book and study. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > assignment problems: have to submit tomorrow |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|