NP59. 提前结束的循环
描述
输入描述
输出描述
示例1
输入:
12
输出:
3 45 9 8
说明:
输出列表12之前的每个数字Python 解法, 执行用时: 12ms, 内存消耗: 2976KB, 提交时间: 2022-07-30
list_num = [3, 45, 9, 8, 12, 89, 103, 42, 54, 79] x = int(input()) for item in list_num: if item == x: break print(item)
Python 解法, 执行用时: 14ms, 内存消耗: 2944KB, 提交时间: 2022-08-01
l = [3, 45, 9, 8, 12, 89, 103, 42, 54, 79] x = int(input()) for n in l: if n != x: print(n) else: break
Python 解法, 执行用时: 14ms, 内存消耗: 2948KB, 提交时间: 2022-08-01
nums_list = [3,45,9,8,12,89,103,42,54,79] num = int(input()) for i in nums_list: if int(i) == num: break print(i) # l = [3, 45, 9, 8, 12, 89, 103, 42, 54, 79] # n = int(input()) # for i in l: # if i-n != 0: # print(i) # else: # break
Python 解法, 执行用时: 14ms, 内存消耗: 2972KB, 提交时间: 2022-08-05
list1 = [3, 45, 9, 8, 12, 89, 103, 42, 54, 79] x = int(input()) for i in list1: if i == x: break else: print(i)
Python 解法, 执行用时: 14ms, 内存消耗: 3028KB, 提交时间: 2022-08-04
list1 = [3, 45, 9, 8, 12, 89, 103, 42, 54, 79] x = input() x = int(x) for i in list1: if i == x: break else: print(i)