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