贪心组最小数

#include <stdio.h>
int main(){
	int count[10];
	for(int i =0; i<10; i++) {
		scanf("%d",&count[i]);
	}
	for(int i=1; i<10; i++) {  //从1~9中选择 count不为0的最小的数字
		if(count[i]>0) {
			printf("%d",i);
			count[i]--;
			break;  //找到一个之后就中断
		}
	}
	for(int i=0; i<10; i++) {  //从0~9输出对应个数的数字
		for(int j=0; j<count[i]; j++) {
				printf("%d", i);
		}
	}
	return 0;
} 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2021-06-05
  • 2021-06-01
  • 2021-10-17
  • 2021-05-29
猜你喜欢
  • 2022-12-23
  • 2021-08-16
  • 2021-06-21
  • 2021-12-09
  • 2021-11-07
  • 2022-12-23
  • 2021-10-20
相关资源
相似解决方案