饭没白吃。。。。 想到了
How are you 怎么是你?
How old are you 怎么老是你?
#include "string" #include <stdio.h> #define TNUM 10000000 char result[TNUM]; char * DeleteNumber(char * strSource, long k) { *result=*strSource; long Num[10]={0L,-1L,-1L,-1L,-1L,-1L,-1L,-1L,-1L,-1L}; long length=strlen(strSource); Num[strSource[*Num]-'0']=0; if((k=length-k)<=0) return "0"; for(int i=1;i!=length;++i) { if(*Num+length-i+1==k) { sprintf(result+*Num+1,"%s",strSource+i); result[k]=0; return result; } if(result[*Num]>strSource[i]) { int j; for(j=strSource[i]+1-'0';j!=10;++j) if(Num[j]!=-1) if(Num[j]+length-i+1>k) { result[*Num=Num[j]]=strSource[i]; for(int temp=j;temp!=10;++temp)Num[temp]=-1; break; } else { *Num-=length-i-k; sprintf(result+*Num,"%s",strSource+i); result[k]=0; return result; } Num[strSource[i]-'0']=*Num; continue; } else if(result[*Num]<strSource[i]) Num[strSource[i]-'0']=*Num+1; result[++*Num]=strSource[i]; } result[k]=0; return result; }