calculate the number of different letters and compare

my question: if the number of four and five letter words input is equal, then your program should have no output. Otherwise output either the four or five letter words, whichever is greater in number. You may output them in any order. Your program will have no other output (so no prompts, names, greetings etc.)

I want to use if statement to do, but my count always is both, how to

Separate to calculate ?

my program:

int a,b;
int count;
If(word.length() == 4){
a = count++;
return a;
If(word.length() == 5){
b = count++;
return b;
If(a > b){
cout << word << endl;
If (a==b){exit 1;}
If (a < b){
cout << word << endl;
Hint : There are a number of four-letter words and a number of five-letter words all stored in a certain container. Use this to your advantage.
yes, I know, but how to stored in a certain container?
> Yes, I know, but how to stored in a certain container?
What do you want to do? Store what in a certain container?
you said: "There are a number of four-letter words and a number of five-letter words all stored in a certain container."
how to store four-letter words and a number of five-letter words in a certain container.
You need to output either the 4-letter words or the 5-letter words. Depending on which type appears more frequently. You might not won't know which is more frequent until the very end of the input, so you need to store both sets of words.

I'd create two vectors of strings: one for the 4-letter words and one for the 5-letter words. Read the input and store each word in the appropriate container. WHen you're dong reading the input, print out the contents of one vector or the other, depending on which is larger.
> How to store four-letter words and a number of five-letter words in a certain container.
This has been done in a couple of examples others gave you. Even mine was involved.

So if I were to ask you, can you point out the line of code that "store four-letter words and five-letter words in a certain container"? Do you know what the "certain container" I am referring to?
Sorry, closed account 5a8Ym39o6, this is my fault
just a note for the future :+)

There also shouldn't be 2 topics about essentially the same subject. There is a risk that the same things will be said in both, possibly making it a time waster for those who reply.

Topic archived. No new replies allowed.