write programs using object-oriented programming (code)
Application of vector and string classes in STL library for building statistical program text:
a, Open/Read a passage from a text file
b, Count the number of sentences in paragraphs
c, Count the words in each sentence
d, Find words in the text that appears that most
e, Sort ascending words (dictionary order) in the text
f, Output results to text file
No one is going to do the work for you, You're going to have to do it your self, we'd all be glad to help you along the way though. Do you have any code to post for us? So we have an idea as to where you are at?
We'll help you if and only if you show us some code first. But because I feel very generous today I'll help you get started ;D
- Open/Read a passage from a text file
Use strings to store the input.
- Count the number of sentences in paragraphs
What characters is a sentence terminated with in your file? '.', '?', '!' could be some I assume... And how do you know when a new paragraph starts? Is newline character ('\n') the answer? If so, count the number of '.', '?', '!' between each pair of consecutive '\n's.
- Count the words in each sentence
I'd count the number of space characters in each sentence.
- Find words in the text that appears that most
Use a map<string,int>.
- Sort ascending words (dictionary order) in the text
Use a vector of strings to store the words of the text and then sort that vector.
I am a first year girl student, I just learn C + +. I have to send fold this project for my teacher. If I do not send on time, I will be point zero. Please help me this time.
Help me write a C + + program completed
Thanks a lot.
I just do part the a, b, c. Now the d and e do not know. Please help me
Code:
a,
void readdata(istream& input,string& s)
{
getline(input,s);
}
b,
int count_sentences(string s, int& number_sentences,int& d_sentences)
{
int l=s.size();
for(int i =0;i < l;i++)
{
if(s[i]=='?'||s[i]=='.'||s[i]=='!')
number_sentences ++;
if((s[i]=='?'||s[i]=='!'||s[i]=='.')&&(s[i+1]=='?'||s[i+1]=='?'||s[i+1]=='!'||s[i+1]=='.'))
d_sentences ++;
}
return number_sentences-d_sentences;
}
c,
int count_words(string& s,int& number_words,int& d_words)
{
I am a first year girl student, I just learn C + +. I have to send fold this project for my teacher. If I do not send on time, I will be point zero. Please help me this time.
Help me write a C + + program completed
Thanks a lot.
I just do part the a, b, c. Now the d and e do not know. Please help me
Code:
a,
void readdata(istream& input,string& s)
{
getline(input,s);
}
b,
int count_sentences(string s, int& number_sentences,int& d_sentences)
{
int l=s.size();
for(int i =0;i < l;i++)
{
if(s[i]=='?'||s[i]=='.'||s[i]=='!')
number_sentences ++;
if((s[i]=='?'||s[i]=='!'||s[i]=='.')&&(s[i+1]=='?'||s[i+1]=='?'||s[i+1]=='!'||s[i+1]=='.'))
d_sentences ++;
}
return number_sentences-d_sentences;
}
c,
int count_words(string& s,int& number_words,int& d_words)
{
Ok, seriously now, it would be good if you also posted the contents of your file (if it's not big) so that we know what we're actually dealing with. If it's big, just post a small part indicating the format of the file.
And use code tags for your code, like this:
[code] /*your code here*/ [/code ] (<-without this extra space here, before ']')
and output tags for the contents of the file, like this:
[output] contents of file here [/output ] (<-without this extra space here, before ']')