I would use a for loop to read every letter gone through into a new string until a whitespace is encountered. Then begin to read into another string until another whitespace is found, and so on until...
Type: Posts; User: Soulrivers
I would use a for loop to read every letter gone through into a new string until a whitespace is encountered. Then begin to read into another string until another whitespace is found, and so on until...
You could call either
std::cin.get();
or
system("PAUSE");
right before the return 0; at the end of main().
Both of these will stall the program to wait for any user input before closing....
Yeah yeah, I meant algorithm. :P
I'm going to assume that you either haven't learned about vectors yet, or that you are trying to figure this out without using vectors. Anyway, using the vector function sort() would be a better...
Fine, I see your point. I'll try using only tabs in the future, thanks.
How am I? If the tabs don't line up like I want them to, I use spaces to put them in the right position.
Thanks for the solve, Todd Burch, I see now what I did wrong. :p And no, this was not a...
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
// initialize the vector
The reason why I check if u == 0 is that I don't want the the loop to check for a match in the last word if it's the first word anyway, that'd be kind of pointless.
First value for lastword? I use...
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
// initialize the vector
You're right, map hasn't been introduced yet, though sort has. I'm guessing what you're getting at is to use sort to organise the strings in a decreasing (or non-decreasing) order, but how would I...
So, this is the assignment:
3-3. Write a program to count how many times each distinct word appears in its input.
You might recognize it from Accelerated C++.
I have come as far as to...