的问题上,下数

在给定行的基础10的数量。在其下的放电填写相应的数十。

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



#include <iostream>

using namespace std;
const int n = 10;

class BottomArr
{
public:
	BottomArr()
	{
		pre = new int[n];
		bottom = new int[n]{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();

}


版权声明:本文博主原创文章。博客,未经同意不得转载。

posted @ 2015-09-13 11:16  zfyouxi  阅读(157)  评论(0)    收藏  举报