1.  
  2. Download: http://solutionzip.com/downloads/count_list_elements-cpp/
  3. Implement a method countValue() that counts the number of times an item occurs in a linked list. Remember to use the STL list.
  4. int countValue(list front, const int item);
  5. Generate 20 random numbers in the range of 0 to 4, and insert each number in the linked list. Output the list by using a method which you would call writeLinkedList which you would add to the ListP.cpp.
  6. In a loop, call the method countValue() , and display the number of occurrences of each value from 0 to 4 in the list.
  7. The above is to be included in a file named ListP.cpp
  8. The following code needs to go in ListP.cpp. The actual code of the function countValue() needs to be included:
  9. int countValue(list front ,const int item);
  10. using namespace std;
  11. int _tmain(int argc, _TCHAR* argv[]){
  12. list front;
  13. int listCount;
  14. cout <> listCount;
  15. for (int i = 1; i <= listCount; i++)
  16. front.insert(i,rand()%5);
  17. cout << “Original List of Values: ” << endl;
  18. //writeLinkedList(front, ” “);
  19. cout << endl;
  20. for(int j=0;j<5;++j)
  21. cout << countValue (front,j) << endl;
  22. cout << endl;
  23. return 0;
  24. }
  25.  
  26.  
  27. Download: http://solutionzip.com/downloads/count_list_elements-cpp/