I have to write a c++ program to read html code and do bunch of stuff. One thing that i have to do is to count the no of attributes and sort them in descenting out and print out only first 10 frequently used attributes.
I counted them using maps and sorted them using multimaps but now dnt knw how to print only 10 elements
for(std::map<string, int>::iterator it = Element.begin(); it != Element.end(); ++it)
Elements.insert(pair<int, string>(it->second, it->first));
for(std::multimap<int, string>::reverse_iterator it = Elements.rbegin(); it != Elements.rend(); ++it)
{
cout << "Element: " << it->second << " : " << it->first << endl;
}
This is how i did it
an any one please help me display only 10 elements and not all the elements
So I just write this inside the for loop that i have ?
it gives me error on the first line
I am sorry can u please answer me :(
I have my assignment due in couple of hours and its like i am almost there but i am not
i would really really appreciate your help
ISO C++ forbids declaration of `it' with no type
cannot convert`std::reverse_iterator<std::_Rb_tree_iterator<std::pair<const int, std::string> > >' to `int' in initialization
Thank you so very much
Yes i knw this is not my strong side!!
i am doing to go back to my basics in my break
I also have to do one last thing if u can please help me with it
for any element name that did not have a matching ending name, print line containing the element name, colon and the count of the number missing ending elements names for that element.
This is my first and last time doing this please if u could help.