桶排列

class wanghuali {
    private:
        int x;
        int a[1000]={0};
        int m=5;
    public:
        void set(){
            for(int i=0;i<5;i++){
                std::cin>>x;
                a[x]++;
            }
        }
        void get(){
            for(int i=0;i<1000;i++){
                if(a[i]!=0){
                    for(int j=0;j<a[i];j++){
                        std::cout<<i<<" ";
                    }
                }        
            }
        
        }
    
};
#include <iostream>
#include "wanghuali.h"
using namespace std;
int main(){
    wanghuali h;
    h.set();
    h.get();
    return 0;
} 

 

posted @ 2024-01-28 11:19  郭立恒  阅读(12)  评论(0)    收藏  举报