Why is my vector not incrementing?
I have two vectors, one with data and one without. Vector file looks like:
1 1 1 2 3 3 7 7 9 2
and vector count is filled with zeros.
1 2 3 4 5 6 7 8 9 10
|
for (int i = 0; i < file.size(); i++) { //loops through file until end
if (file[i] == i) { //if [0] == 0 then
count[i + 1] = count[i + 1] + 1; //[0] = [0] + 1;
}
}
cout << "Digit Count Frequency" << endl;
for (int p = 0; p < 9; p++) {
cout << " " << digit << " " << count[p + 1] << endl;
digit++;
}
|
Current output:
Digit Count Frequency
1 0
2 1
3 0
4 0
5 0
6 0
7 0
8 1
9 0 |
My desired output is:
Digit Count Frequency
1 3
2 2
3 2
4 0
5 0
6 0
7 2
8 0
9 1 |
Last edited on
Yes, I was trying to not use a nested for but either way that does what it needs too, thank you.
Topic archived. No new replies allowed.