zoukankan      html  css  js  c++  java
  • 的问题上,下数

    在给定行的基础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();
    
    }
    


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

  • 相关阅读:
    SecureCRT
    NFS服务器搭建
    卸载oracle步骤
    redhat 5.5 x86_x64搭建samba服务器
    ORA-01940: cannot drop a user that is currently connected
    迁移表空间
    日常SQL使用总结
    DataGuard常规操作命令
    使用PowerDesginer画ER图
    数据库卸载
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/4804236.html
Copyright © 2011-2022 走看看