讨论 / c语言
r1529087768 2018-02-28 17:45:01
点我顶贴 收藏 删除
#include<stdio.h>

#include<string.h>

int main()

{

char str[256], ans[256];

char *p = ans;

int i, j = 0, k = 0, t = 1, n, min, sum = 0, tmp;

scanf("%s", str);

scanf("%d", &n);

while(strlen(ans) < strlen(str) - n)

{

for(i = j; i <= n + k; i++)

{

if(i == j)*p = 58;

if(str[i] < *p)

{

*p = str[i];

tmp = i;

}

}

j = tmp + 1;

k++;

p++;

}

for(i = strlen(ans) - 1; i > -1; i--)

{

sum += t*(ans[i] - 48);

t *= 10;

}

printf("%d", sum);

return 0;

}

查看更多回复
提交回复