这个用字符串做不难

—>〉Sun〈<—
程序代码:
#include <stdio.h>
#include <string.h>
#include <assert.h>
char* solve(char *m,int s)
{
char *top;//top为栈顶的下一个位置
char *next;//next为下一个要操作的字符
int cnt=0;//已经删去字符的计数器
top=next=m;
while(cnt<s){
if(top!=m && *(top-1)>*next){
top--;
cnt++;
}
else {
*top++=*next++;
}
}
strcpy(top,next);//可优化掉
return m;
}
char m[1000001];
int s;
int main()
{
while(scanf("%s%d",m,&s)!=EOF){
assert("题目中没有说明如果去掉的数字数比原本的数的长度还长时应该输出什么" &&strlen(m)>s);
printf("%s\n",solve(m,s));
}
}