贪心——删数问题

#include <stdio.h>
#include <string.h>
int main()
{ int i, k, s, len;
char a[105];
while(scanf("%s %d", a, &s)!=EOF)
{ for(k=1; k<=s;k++)
{ len=strlen(a); i=0;
while(i<len &&a[i]<=a[i+1]) { i++; }
while(i<len)
{ a[i]=a[i+1]; i++; }
}
len=strlen(a); i=0;
while(i<len&&a[i]==‘0’) i++;
if (i<len)
{ while(i<len) { printf("%c",a[i]); i++; } }
else { printf(“0”); }
printf("\n");
}
return 0;
}

/***************************************************
User name: jk180115王金涛
Result: Accepted
Take time: 0ms
Take Memory: 148KB
Submit time: 2019-04-09 20:52:31
****************************************************/

猜你喜欢

转载自blog.csdn.net/wjt_1025/article/details/89343503