Sign in to follow this  
snowman88

[urgent]about C++.please help!

Recommended Posts

snowman88    122
This is my assignment question: Small advertisements in newspapers often abbreviate words in order to save space. Typically this is done by removing the vowels from the words except for the vowels if it starts a word. For example, the advertisement "3 bedroomed flat very good condition inspection anytime" would be abreviated to "3 bdrmd flt vry gd cndtn inspctn anytm". Write a program which enables a user to input a string (on a line) and which produces as output the input string with the vowels removed in the manner just described. The program continues until there is no more user input. You may assume that the words in the input string are separated by single space characters and that the string contains at least one character. In your program, you should process the string as a vector of characters and you should not use functions in <string> except for declaring the string variables, outputting strings by using insertion operator (<<), inputting strings by using extraction operator (>>) or function getline() and array subscript operator [] (inside a loop) which allows the string to process as a vector of characters. I have no idea about it .Please help!

Share this post


Link to post
Share on other sites
ToohrVyk    1595
If you are unable to propose even a partial solution for this (for instance, reading a string and then outputting it back), then you should follow a C++ course or tutorial, first.

If you are unwilling to propose even a partial solution for this, I see no reason for us to do your homework.

Share this post


Link to post
Share on other sites
snowman88    122
Quote:
Original post by ToohrVyk
If you are unable to propose even a partial solution for this (for instance, reading a string and then outputting it back), then you should follow a C++ course or tutorial, first.

If you are unwilling to propose even a partial solution for this, I see no reason for us to do your homework.


you are right.i have designed the algorithm before.But I have some problem.I want to make a function to break down the whole sentense into word and asign it to vector.I don't know how to do.But my author don't allow me to use array.Can you solve these?

Share this post


Link to post
Share on other sites
ToohrVyk    1595
Do you really need to store the individual words? The only word-related information you need is whether a letter is at the beginning of a word.

Share this post


Link to post
Share on other sites
Chrono1081    108
you could read the string into an array then use a loop to filter out the vowles, starting the loop at 1 instead of 0 to skip that first letter.

Also be careful about posting homework questions on here, they usually only will help you if you have 99.999% of the code already written and your just stuck on a section or if its an assignment already turned in and graded your just asking for extra critique.

Share this post


Link to post
Share on other sites
Chrono1081    108
Another tactic to try would be to break it all down on paper either in a flowchart or pseudocode. Some people would argue that its overkill for a small program but I completely disagree. You can usually figure out a lot better way of solving a problem this way then from writing the code off the top of your head.

Share this post


Link to post
Share on other sites
snowman88    122
Quote:
Original post by Chrono1081
you could read the string into an array then use a loop to filter out the vowles, starting the loop at 1 instead of 0 to skip that first letter.

Also be careful about posting homework questions on here, they usually only will help you if you have 99.999% of the code already written and your just stuck on a section or if its an assignment already turned in and graded your just asking for extra critique.


Oh,sry about it.I don't know this forum has this rule.Thanks a lot!

Share this post


Link to post
Share on other sites
snowman88    122
Quote:
Original post by Chrono1081
you could read the string into an array then use a loop to filter out the vowles, starting the loop at 1 instead of 0 to skip that first letter.

Also be careful about posting homework questions on here, they usually only will help you if you have 99.999% of the code already written and your just stuck on a section or if its an assignment already turned in and graded your just asking for extra critique.


Oh,sry about it.I don't know this forum has this rule.Since this is my first time to here.Thanks a lot!

Share this post


Link to post
Share on other sites
Wan    1366
It's not easy to help you out without giving the entire solution, but perhaps I can help you start thinking in the right direction.

I assume you already have a way to detect whether a character is a vowel or not. So if the assignment would be remove all the vowels in a sentence that shouldn't pose a problem, right? You'd go through all the characters in a line, see if it's a vowel, and if it is you remove it.

Now the actual question is only slightly more complicated: remove the vowels, unless is starts a word. Your initial idea was to split the line up into words and put them in an array. How would detect a word in a sentence? Probably by looking for a sequence of characters that is preceded by a space (unless it's the very first word). So as you're iterating through the characters in the sentence you encounter the start of a word, you could save and use that information to determine whether you can remove a possible vowel or not.

Share this post


Link to post
Share on other sites
Wan    1366
Quote:
Original post by snowman88
here is my work,but i can't compile it.Can everyone tell me what the mistakes are?

I don't want to sound too harsh, but I'm not even going to look at the code before you can at least tell why it doesn't compile (other posters may have a different opinion though). What does your compiler say? And what does this tell you?

Also, source tags are the preferred method for posting code.

Share this post


Link to post
Share on other sites
Yann L    1802
Since you seem to have solely registered for this, you may have missed the line on top of your screen that reads gamedev.net, rather than your-personal-homework-assistant.net

Closed.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this