#include <iostream.h> #include <string.h> int main() { char a[241]; int b[240]; int m,flag; int i,j; int first,second; while(cin>>a>>m) { for (i=0;i<strlen(a);i++) b[i]=0; for (i=0;i<m;i++) { flag=1; first=0; while(flag) { while(b[first]==1) first++; if (first+1==strlen(a)) { b[first]=1; break; } second=first+1; while(b[second]==1) second++; if (a[first]>a[second]) { b[first]=1; flag=0; } first++; } } for (i=0;i<strlen(a);i++) if (b[i]==0) cout<<a[i]; cout<<endl; } }

评论