#include <stdio.h> int main(void) { int arr[5]={2,5,1,3,3}; //定义需要排序的数组 int res[6]={0}; //初始化“桶”为0 for(int i = 0 ; i < 5 ; i ++) { res[arr[i]] = res[arr[i]] + 1; //统计“桶”中,0,1,2,3,4,5这六个数字出现的次数 ,每出现一次就加1 } for(int b = 0 ; b < 6 ;b ++) { while(res[b]>0) { printf("%d ",b); //将“桶”中0,1,2,3,4,5这六个数字只要出现次数大于0就打印出来 res[b] --; // 如果有出现1一次以上就循环打印出现的次数遍的这个数字 } } }
如对本文有疑问, 点击进行留言回复!!
SP8093 JZPGYZ - Sevenk Love Oimaster(广义SAM)
[2020牛客暑期多校训练营第三场] L.Problem L is the Only Lovely Problem 字符串函数
Qt——BUG:构造函数中new了控件并隐藏了,后续显示时位置不对?
PAT甲级 1087. All Roads Lead to Rome (30) (dijkstra)
网友评论