Jump to content
  • Advertisement
Sign in to follow this  
snowman88

[urgent]about C++.please help!

This topic is 3793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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
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
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
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
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
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

This topic is 3793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!