Topic:
To give an example:
Value: 0,1,2,3,4,5,6,7,8,9
Allocation: 6,2,1,0,0,0,1,0,0,0
0 appeared in the lower row 6 times, 1 in the lower row appeared 2 times.
2 appeared in the next row, ...
And so on
#include <iostream>
using namespace Std;
#define LEN 10
Class NUMBERTB
{
Private
int Top[len];
int Bottom[len];
BOOL success;
Public
NUMBERTB ();
int* Getbottom ();
void Setnextbottom ();
int getfrequency (int num);
};
NUMBERTB::NUMBERTB ()
{
Success = false;
Format Top
for (int i = 0; i < len;i++)
{
Top[i] = i;
}
}
int* Numbertb::getbottom ()
{
int i = 0;
while (!success)
{
i++;
Setnextbottom ();
}
return bottom;
}
Set Next Bottom
void Numbertb::setnextbottom ()
{
bool ReB = true;
for (int i = 0; i < len; i++)
{
int frequecy = getfrequency (i);
if (bottom[i]! = frequecy)
{
Bottom[i] = Frequecy;
ReB = false;
}
}
Success = ReB;
}
Get frequency in Bottom
int numbertb::getfrequency (int num)//Here num refers to the number of rows I
{
int count = 0;
for (int i = 0; i < len; i++)
{
if (bottom[i] = = num)
count++;
}
Return count;//count that corresponds to frequency
}
int main ()
{
NUMBERTB NTB;
int* result = Ntb.getbottom ();
for (int i = 0; i < len; i++)
{
cout << *result++ << Endl;
}
System ("pause");
return 0;
}
To find the number of rows that appear in the next row