1023 组个最小数 (20 分)

mac2022-06-30  66

题目链接:1023 组个最小数 (20 分)

 

这道题目比较简单,将0的个数单独统计,其它数字组成的新数按从小到达排列组成。然后将若干个0插入到第一个

非零数字之后即可。

 

1 #include <bits/stdc++.h> 2 using namespace std; 3 4 string ans; 5 int main() 6 { 7 int a[10]={0}; 8 int count,count0; 9 cin>>count0; 10 for(int i=1;i<10;i++) 11 { 12 cin>>count; 13 for(int j=0;j<count;j++) 14 ans+=i+'0'; 15 } 16 for(int i=0;i<count0;i++) 17 ans.insert(1,"0"); 18 cout<<ans<<endl; 19 return 0; 20 }

 

转载于:https://www.cnblogs.com/ManOK/p/10188625.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)