Python-CCF:20180901 卖菜

题目描述

在这里插入图片描述

用时

写代码用了十分钟,debug了四十分钟
???
天杀的CCF
用Python的同学注意了
split(' ')作输入的分割可能有坑
如果题目描述没有明确的说输入是用空格分割的那么就不要用split(' ')
种苹果那道题说了
在这里插入图片描述而卖菜这道没说
没说的话测试用例有可能是用其他的空白字符分割的
这时用split(' ')就分割不了了
所以统一换用split(),以任意的空白字符进行分割
我真是服了
在这里插入图片描述

代码

if __name__ == "__main__":
    store_num = int(input())
    first_prices = list(map(int, input().split()))
    second_prices = []

    second_prices.append(int((first_prices[0] + first_prices[1]) / 2))
    for store_no in range(1, store_num-1):
        second_prices.append(int((first_prices[store_no-1] + first_prices[store_no] + first_prices[store_no+1]) / 3))
    second_prices.append(int((first_prices[-1] + first_prices[-2]) / 2))

    for sp in second_prices:
        print(sp, end=' ')

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值