my program:
#include<iostream>
#include<vector>
#include<string>
#include<cctype>
#include <stdio.h>
using namespace std;
int main ()
{
vector<string> s;
string word;
cout << "Enter your words, EOF to quit: " << endl;
while (cin >> word)
{
if (word.length () == 4 || word.length () == 5)
{
for (size_t i = 0; i < word.size (); ++i)
word[i] = tolower (word[i]);
s.push_back(word);
}
}
system ("pause");
return 0;
}
Now I can input and store four and five letter words, but how to compare their numbers, and find the bigger one.
You declare two counter variables. For example, counter1 is for four-letter words and counter2 is for five-letter words. You iterate though the container and you make sure that you increase counter1 by one unit when you encounter a four-letter word, and counter2 by one unit when you encounter a five-letter word.
Ok, let's take a break. Let's see how well you can solve the problem.