In a game,Children is requested to take S (1<=S<N) digits from a big number which has N digits (1<N<240),when they have taken all the S digits form the number ,all the digits left should be the most minimum if the order of the digits left is

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 19:57:10

In a game,Children is requested to take S (1<=S<N) digits from a big number which has N digits (1<N<240),when they have taken all the S digits form the number ,all the digits left should be the most minimum if the order of the digits left is
In a game,Children is requested to take S (1<=S<N) digits from a big number which has N digits (1<N<240),when they have taken all the S digits form the number ,all the digits left should be the most minimum if the order of the digits left is not changed.Please write a program to help him.
Input
Input includes n test cases.Each line contains one case with two numbers.First one of it is the number to be taken; the second is the number of digits the children should take.
Output
Output the minimum number left for each case.
Sample Input
1458734 3
2324876 4
Sample Output
1434
224
我的代码:
#include
#include
using namespace std;
int main()
{
int i,j,h,n,index,count;
char ch,a[240];
while(cin>>a>>n)
{
h=strlen(a); // 可能有0
count=h-n;
index=-1;
for(j=0;j

In a game,Children is requested to take S (1<=S<N) digits from a big number which has N digits (1<N<240),when they have taken all the S digits form the number ,all the digits left should be the most minimum if the order of the digits left is
//代码已AC,整理了一下
//在删除数字数量与S长度相等时需输出0
#include
#include
using namespace std;
int main()
{
char a[241];
int n,i,j,h;
while(cin>>a>>n)
{
h=strlen(a);
if(n == h) //n至少要比字符串短1
n --;
for(i=0,j=0;i