1 solutions
-
0
#include <iostream> #include <string.h> #include <algorithm> using namespace std; const int N = 255; int k; char x[N]; int main(){ cin >> x >> k; int sz = 0; sz = strlen(x); while(k){//k次删除 int i = 0; for(i = 0;x[i] <= x[i+1] && i < sz - 1;i++){}//找到峰值 if(i == sz - 1){//到末尾,则删去最后一位 sz--; }else{ for(int j = i;j < sz - 1;j++){ x[j] = x[j + 1];//删去峰值 } sz--; } k--; } int st = 0; for(st = 0;x[st] == '0';st++);//删前导0 bool flg = 0; for(int i = st;i < sz;i++) { cout << x[i]; flg = 1; } if(flg == 0) cout << 0;//全删光时输出0 return 0; }
- 1
Information
- ID
- 106
- Time
- 1000ms
- Memory
- 125MiB
- Difficulty
- 3
- Tags
- # Submissions
- 12
- Accepted
- 5
- Uploaded By