原文链接:https://blog.csdn.net/qq_41023125/article/details/105748780
先放上地址:https://ac.nowcoder.com/acm/contest/320#question
1、A+B(1)
while True:
try:
a, b = map(int, input().strip().split())
print(a + b)
except EOFError:
break
- 1
- 2
- 3
- 4
- 5
- 6
2、A+B(2)
while True:
try:
l = list(map(int, input().strip().split()))
if len(l) == 1:
pass
else:
print(sum(l))
except EOFError:
break
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
3、A+B(3)
while True:
try:
l = list(map(int,input().strip().split()))
if l == [0,0]:
break
else:
print(sum(l))
except EOFError:
break
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
4、A+B(4)
while True:
try:
l = list(map(int, input().strip().split()))
if l[0] == 0:
break
else:
print(sum(l[1:]))
except EOFError:
break
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
5、A+B(5)
while True:
try:
l = list(map(int,input().strip().split()))
if len(l) == 1:
pass
else:
print(sum(l[1:]))
except EOFError:
break
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
6、A+B(6)
while True:
try:
l = list(map(int, input().strip().split()))
print(sum(l[1:]))
except EOFError:
break
- 1
- 2
- 3
- 4
- 5
- 6
7、A+B(7)
while True:
try:
l = list(map(int, input().strip().split()))
print(sum(l))
except EOFError:
break
- 1
- 2
- 3
- 4
- 5
- 6
8、字符串排序(1)
while True:
try:
n=int(input())
mystr=list(map(str,input().strip().split()))
mystr.sort()
print(' '.join(mystr))
except EOFError:
break
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
9、字符串排序(2)
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.lstrip())
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
10、字符串排序(3)
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)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
参考:
- https://www.pythonheidong.com/blog/article/319732/#n_302
- https://www.cnblogs.com/Komnenos/p/nowcoderIo.html
</div><div><div></div></div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-ff98e99283.css" rel="stylesheet">
</div>