Vector, counting repetitive numbers

hi guys..this short program is almost done..but the last part been beating me up since 3 days now..so am going to post the whole code here then we go straight to the problem

#include <iostream>
#include <vector>
using namespace std;
int const RESET = 0;
int ROW=44;
int LN [][5]={
/* 0*/ {37,13, 20, 84, 90},
/* 1*/ {26,83, 90, 72, 79},
/* 2 */{41,80, 39, 60, 40},
/* 3*/ {4, 46, 85, 61, 9 },
/* 4*/ {44,62, 74, 70, 49},
/* 5*/ {28,33, 72, 62, 88},
/* 6*/ {20,5, 6, 25, 71},
/* 7 */ {3, 9, 15, 84 ,34},
/*8*/{7, 52, 25, 83, 88},
/* 9*/{15,35, 67, 78, 6},
/*10*/ {53,38, 2, 10, 49},
/*11*/ {43,83, 17, 37, 15},
/*12*/ {90,36, 59, 3, 64},
/*13*/ {59,19, 28, 58, 76},
/*14*/ {51,81, 2, 8, 67},
/* 15/*/{64,72, 45, 86, 5},
/* 16*/{77,89, 38, 72, 45},
/*17*/{34,1, 74, 61, 89},
/*18*/{31,25, 75, 37, 84},
/*19*/ {23, 59, 57, 50, 77},
/*20*/ {79,90, 1, 23, 16},
/*21*/ {25,34, 22, 84, 7},
/*22*/ {70,46, 30, 37, 90},
/*23*/ {72,55, 75, 64, 71},
/*24*/ {90,8, 84, 36, 30},
/*25*/ {34,79, 81, 20, 12},
/*26*/ {82,56, 77, 49, 69},
/* 27*/ {42,30, 89, 84, 59},
/*28*/ {10,6, 68, 50, 87},
/*29*/ {28,7, 55, 62, 58},
/*30*/ {31,25, 86, 84, 87},
/*31*/ {36,66, 53, 3, 77},
/*32*/ {25,13, 72, 70, 47},
/*33*/{34, 77,80, 53, 33},
/*34*/ {86, 71, 23, 90, 8},
/*35*/{81, 45, 69, 38, 72},
/*36*/ {24, 61, 74, 41, 72},
/*37*/ {30, 27, 66, 43, 13},
/*38*/ {69, 20, 15, 64,59},
/*39*/ {14, 28, 59, 42, 67},
/*40*/ {2, 31, 88, 28, 55},
/*41*/{60, 73, 63, 19, 82},
/*42*/{67, 4, 42, 27, 29},
/*43*/ {16, 2, 51, 19, 74}
};
int r, c, k, Possiblenumbers1, Numberofpossiblenum=0;

int main ()
{
vector<int> Tally;

//1ST rolling, roll will be minus 2
for (r=0; r<ROW-2; r++)for (c=0;c<5;c++) /*locking a particular row, in this case starting from row 0*/

{
if(LN[r][c]==LN [ROW-1][0]
||LN[r][c]==LN [ROW-1][1]
||LN[r][c]==LN [ROW-1][2]
||LN[r][c]==LN [ROW-1][3]
||LN[r][c]==LN [ROW-1][4]) /*if at least a figure of row analysed equal to a figure of jumping board row*/
{r+=1; Numberofpossiblenum+=5; // rolling one, would be r=+2 if rolling 2, or 3 if rolling 3 and so on...
cout<<endl<<"Row number:"<<r<<endl;
for (c=0;c<5;c++)
{Tally.push_back(LN[r][c]);
cout<<LN[r][c]<<", ";
}
}
}
cout<<endl<<endl<<"Number of possible numbers are: "<<Numberofpossiblenum<<endl<<endl;
cout<<"...and they are:\n";
for(int i=0;i<Tally.size();i++)
cout<<Tally[i]<<", ";

int i,n,j,counter;


cout<<endl<<endl<<"We will now find how many times numbers are repeated."<<endl<<endl;

for (i=0;i<Numberofpossiblenum;i++)
{
for (j=0;j<Numberofpossiblenum;j++)
{
if(Tally[i] == Tally[j])
{
counter+=1;
// Tally.erase(Tally.begin()+j-1);
}
}
cout<<endl<<"Value "<<Tally[i]<<" repeated "<<counter<<" times!"<<endl;
}


return 0;
}


Ok so this is the whole code! the problem is at the end from where i have cout<<we will now find out how many times numbers are repeated. from there on i've been trying to write in a way so that the numbers in vector Tally are checked to see how many times they repeat...but i've havent been able to do anything good...guys help me please...thank you soo much in advance. what i have there is not working well...giving me some strange things :( help...thanks
You could build a map holding the counts:

1
2
3
4
5
std::map<int, unsigned> counts;
for(auto n: Tally)
    ++counts[n];
for(auto p: counts)
    std::cout << "Value " << p.first << " repeated " << p.second << " times!\n";
Topic archived. No new replies allowed.