Vector and fstream problems - visual studio

Thank you for the insight James, I have it working 95% after staring at it for an hour.
Last edited on
1
2
3
4
5
6
7
vector <int> min_positions(4);
int min;

for(int x=0; x<5; x++)
{
       min_positions[x] = 0;
}


-Create a vector that can hold 4 elements
-Loop through and try and access 5 elements (0,1,2,3,4)
I just changed both of the 5's in those two for loops to 4's. I am still getting the same error message, but the program prints the four recommended digits this time as all 0's, which is incorrect but progress :)
Correction, changed it in all of the loops and am now getting no error message, but I am still printing out all 0's for the recommended numbers, so the problem is now somewhere in my logic instead my syntax.
Last edited on
The idea was to find the least used digits in the 10 element vector, and then put their positions (which represent the digits 0-9, the elements represent the number of times they are used in the text file) in the 4 element vector. When an element is chosen and put into the 4 element vector, its value is changed to -1 so that it will not be chosen again.
The text file reads:

5 4 0 7
7 1 7 8
0 0 6 9
4 4 9 1
3 9 2 8
3 7 2 7
9 8 1 8
2 9 1 2
-1
Last edited on
Topic archived. No new replies allowed.