Python3 acm基础输入输出


案例一:输入字符串分割并转化成多个int数值
a, b= map(int, input().split())
try:
  while True:
    a, b= map(int, input().split())
    print(a+b)
except EOFError:
    pass

 

案例二:输入一个数值转化为int
t =int(input().strip())
t =int(input().strip())
while t > 0:
    a,b=map(int,input().split())
    print(a+b)
    t=t-1

 

案例三:if判断
while True:
    a, b= map(int, input().split())
    if a==0 and b==0 :
        break
    print(a+b)

 

案例四:每组之间保留一个空行
print('\r')
t = 0
while True:
    a, b= map(int, input().split())
    if a==0 and b==0 :
        break
    if t > 0:
        print('\r')
    print(a+b)
    t = t + 1

 




免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM