I'm using the map to count the words of the word. Here I have the code.
#include & lt; Iostream & gt; # Include & lt; Map & gt; #include & lt; String & gt; using namespace std; Int main () {map & lt; String, int & gt; Wordcount; String s; While (cin> gt; s & amp; amp; s! = "Red") ++ word quota [s]; While (cin> gt; s & amp; s! = "Red") cout & lt; & Lt; S & lt; & Lt; "" & Lt; & Lt; Vercount [S] & lt; & Lt; Endl; Return 0; } Let's start the program, type the word and enter the word "red" in the last line, but it does nothing. Then I type "red" for the second time and it outputs:
Press any key to continue
What's wrong?
There is too much alcohol to write here, but I will try another time :)
< P> If you type a lot of words, they will count unless the second loop prints the count for your input, but if you immediately put "red", then this program can be printed without any printing Will finish.Try running the program with the following input:
one two two red zero one two red
Comments
Post a Comment