求大佬帮忙看一下python
  • 板块P1106 删数问题
  • 楼主LMS_yr
  • 当前回复1
  • 已保存回复1
  • 发布时间2022/3/7 14:41
  • 上次更新2023/10/28 07:05:15
查看原帖
求大佬帮忙看一下python
681120
LMS_yr楼主2022/3/7 14:41

在pycharm上运行没有发现问题 求指点 代码如下:

def f(listx, x):
    od = 0
    op = len(listx)
    while x != 0 and od < op-1:
        if listx[od] > listx[od+1]:
            if od == 0 and listx[od+1] == 0:
                od += 1
                continue
            listx.pop(od)
            x = x-1
            op = op-1
            od = 0
            continue
        od += 1
    return x
m = input()
n = int(input())
list1 = list(m)
list1 = [int(i)for i in list1]
rest = len(list1)
n = f(list1, n)
list1 = [str(i)for i in list1]
n = int(n)
if n == 0:
    c = ''.join(list1)
    c.strip()
    print(c)
else:
    y = len(list1)-n
    if y == 1 and list1[1] == 0:
        print('0')
    else:
        list1[y:] = ' '
        c = ''.join(list1)
        c.strip()
        print(c)
2022/3/7 14:41
加载中...