其他分享
首页 > 其他分享> > 桶排序C语言代码

桶排序C语言代码

作者:互联网

#include <iostream>  
#include <cstdio>    
using namespace std;    
int a[1001], num, n, cnt=0;  
int main() {  
    cin >> n;  
    for (int i = 1; i <= n; i++) {  
        cin >> num;  
        a[num]++;  
        if (a[num] == 1)  
            cnt++;  
    }    
    cout << cnt << endl;  
    for (int i = 1; i <= 1000; i++) {  
        if (a[i] > 0) {  
            cout << i << " ";  
        }  
    }    
    return 0;  
}  

 

标签:cnt,include,cout,int,代码,C语言,++,num,排序
来源: https://www.cnblogs.com/guojianyu/p/16685069.html