牛客练习输入输出场:(1条未读通知) 牛客竞赛_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ (nowcoder.com)

连续输入输出
while True:
try:
a,b=map(int,input().split())
print(a+b)
except:
break
while True:
try:
cin=list(map(int,input().split()))
print(sum(cin))
except:
break
输入指定数量的连续输入

n=int(input())
for _ in range(n):
a,b=map(int,input().split())
print(a+b)
连续输入到指定数字,例如0 0

while True:
a,b=map(int,input().split())
if a==0 and b==0:
break
else:
print(a+b)
输入的每行长度不一,遇到指定符0停止输入

while True:
cin=list(map(int,input().split()))
if cin[0]==0:
break
else:
print(sum(cin[1:]))
每行传入不定行:

while True:
try:
cin=list(map(int,input().split()))
print(sum(cin))
except:
break
本文介绍牛客网上的输入输出练习题目,包括多种输入输出处理方式,如连续输入输出、指定数量的输入处理及遇到特定条件停止输入的方法。通过这些实例,读者可以更好地掌握Python中输入输出操作。
1072

被折叠的 条评论
为什么被折叠?



