您的位置:首页 > 其它

的问题上,下数

2015-09-13 11:16 176 查看
在给定行的基础10的数量。在其下的放电填写相应的数十。

需要的下一行的每个数字是数十次出现在低行的行上。

#include <iostream>

using namespace std;
const int n = 10;

class BottomArr
{
public:
BottomArr()
{
pre = new int
;
bottom = new int
{0};
for (int i = 0; i < n; i++)

{
pre[i] = i;
}

}
~BottomArr()
{
delete[]pre;
delete[] bottom;
}
void getArr()
{
bool flag = true;
while (flag)
{
flag = false;
for (int i = 0; i < n; i++)
{
int count = getcount(i);
if (count != bottom[i])
{
bottom[i] = count;
flag = true;
}

}
}
for (int i = 0; i < n; i++)
{
cout << bottom[i]<<" , ";
}

}

int getcount(int i)
{
int count = 0;
for (int j = 0; j < n; j++)
{
if (bottom[j] == i)
{
count++;
}
}
return count;
}

int *bottom;
int *pre;

};

void main()
{
BottomArr arr;
arr.getArr();
cout << "结束" << endl;
cin.get();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: