http://pat.zju.edu.cn/contests/pat-b-practise/1023
// PAT,简单题集
// 给几个数字,任意组合,0不可为首,求最小数
//
#include <stdio.h>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#define SIZE 100
using namespace std;
int main(){
#ifdef ONLINE_JUDGE
#else
freopen("E:\\in.txt", "r" , stdin);
#endif
int t, i=0,n=0;
int buf[SIZE];
while(scanf("%d", &t) != EOF)
{
buf[0]=t;
for(i=1;i<10;i++)
{
scanf("%d", &t);
buf[i]=t;
}
if(buf[0] > 0)
{
int pos=1;
for(pos=1; pos<10 && buf[pos] == 0; pos++)
{
;
}
printf("%d", pos);
buf[pos]--;
}
for(i=0;i<10;i++)
{
while(buf[i]-- > 0)
{
printf("%d", i);
}
}
cout << endl;
}//while
return 0;
}
本文介绍了一道PAT竞赛中的算法题目,旨在通过给定的一组数字构造出可能的最小数值,要求数字不可重复使用且首位不能为0。文章提供了完整的C++代码实现,并详细解释了如何遍历数字并按照从小到大的顺序排列来构成最终的最小数值。

1697

被折叠的 条评论
为什么被折叠?



