python牛客算法题的11种输入输出方案

import sys
for line in sys.stdin:
    a = line.split()
    print(int(a[0])+int(a[1]))

t = int(input())
for _ in range(t):
    a, b = map(int, input().split(" "))
    print(a+b)

while True:
    lst = list(map(int,input().split()))
    if(lst[0]==0 and lst[1]==0):
        break
    print(sum(lst))

while True:
    try:
        a=list(map(int, input().split()))
        if a[0]==0:
            break
        else:
            print(sum(a[1:a[0]+1]))
    except:
        break

import sys
n=input()
for line in sys.stdin:
    line=list(map(int,line.split()))
    #a=line.split()
    print(sum(line[1:]))
            
while True:
    try:
        list1 = list(map(int, input().split()))
        n = list1[0]
        sum = 0
        for i in range(1, len(list1)):
            sum += list1[i]
        print(sum)
    except:
        break

import sys
for line in sys.stdin:
    li = list(map(int, line.split()))
    print(sum(li[:]))

while True:
    try:
        n = int(input())
        a = list(map(str,input().split()))
        print(' '.join(sorted(a)))
    except:
        break

while True:
    try:
        line = list(map(str,input().split(' ')))
        line.sort(reverse=False)
        print(' '.join(sorted(line)))
    except:
        break

while True:
    try:
        a = list(map(str,input().strip().split(',')))
        print(','.join(sorted(a)))
    except:
        break

while True:
    try:
        a = list(map(int,input().split()))
        print(a[0]+a[1])
    except:
        break

你可能感兴趣的:(python牛客算法题的11种输入输出方案)