Python 代码:查找输入数字中的最大值
n=int(input('请输入数字的个数:')) max=-float('inf') # 初始化最大值为负无穷大 for k in range(n): x=float(input('请输入第{}个数:'.format(k+1))) # 输入的提示内容为:请输入第1个数、请输入第2个数等 if x>max: max=x # 更新最大值 print('输入的{}个数中最大值为:{}'.format(n,max))
原文地址: https://www.cveoy.top/t/topic/oKf2 著作权归作者所有。请勿转载和采集!