In a game,Children is requested to take S (1<=S<N) digits fr

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
mingning179 1年前 已收到1个回答 举报

cnhe_110 幼苗

共回答了19个问题采纳率:94.7% 举报

//代码已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

1年前

1
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.053 s. - webmaster@yulucn.com