求查错(写了半个中午,改了整个中午,最后wa掉了······)
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
struct number{
int num;
int place;
}a[10010];
int main()
{
string n ;bool bre = 0;
int k;
cin >> n >> k;
int len = n.length();
for (int i = 0;i <= len; i ++){
a[i].num = n[i];
a[i].place = i ;
}
while(k --){
for(int i = 9;i >= 1;i --){
for(int j = 0;j <= len;j ++){
if ( a[j].num == i){
a[j].num = a[j].place = -1;
bre = 1;
break;
}
}
if (bre == 1){
bre = 0;
break;
}
}
}
int hahaha;
for (int i = 0;i <= len;i ++){
if (a[i].num == -1) hahaha = 1;
else cout << a[i].num;
}
return 0;
}