# 牛客网IO练习

2019/12/06 02:46

#牛客网IO练习

[toc]

## 1. 计算a+b

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


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


## 2. 计算a+b

python自带input，直接用python自带的input。

num = input()
num = int(num)
for i in range(num):
a = input()
Input_Num = a.split()
print(int(Input_Num[0]) + int(Input_Num[1]))


import fileinput
num = input()
num = int(num)
for line in fileinput.input():
a = line.split()
print(int(a[0])+int(a[1]))


## 3. 计算a+b

from fileinput import input
for line in input():
a = line.split()
if int(a[0])!=0 and int(a[1])!=0:
print(int(a[0])+int(a[1]))
else:
break


## 4. 计算a+b

from fileinput import input
for line in input():
a = line.split()
for i in range(len(a)):
a[i] = int(a[i])
if a[0] != 0:
print(sum(a)-a[0])
else:
break


## 5. 计算a+b

import fileinput
num = int(input())
for i in fileinput.input():
n = i.split()
n = list(map(lambda x:int(x),n))
print(sum(n)-n[0])


## 6. 计算a+b

from fileinput import input
for line in input():
a = line.split()
a = list(map(lambda x:int(x),a))
print(sum(a)-a[0])


## 7. 计算a+b

from fileinput import input
for line in input():
a = line.split()
a = list(map(lambda x:int(x),a))
print(sum(a))


## 8. 字符串排序

num = int(input())
line = input()
a = line.split()
a = sorted(a)
s = ''
for i in range(num - 1):
s += a[i] +' '
s += a[-1]
print(s)


## 9. 字符串排序

from fileinput import input
for line in input():
a = line.split()
a = sorted(a)
s = ''
for i in range(len(a)-1):
s+=a[i]+' '
s += a[-1]
print(s)


## 10. 字符串排序

from fileinput import input
for line in input():
a = sorted(line.strip().split(','))
s = ''
for i in range(len(a)-1):
s+=a[i]+','
s += a[-1]
print(s)


0
0 收藏

0 评论
0 收藏
0