티스토리 뷰

728x90

https://www.acmicpc.net/problem/2870

 

2870번: 수학숙제

종이에서 찾은 숫자의 개수를 M이라고 하면, 출력은 M줄로 이루어져야 한다. 각 줄에는 종이에서 찾은 숫자를 하나씩 출력해야 한다. 이때, 비내림차순으로 출력해야 한다. 비내림차순은 내림차

www.acmicpc.net

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
ans = []
for _ in range(int(input())):
    S = input()
    tmp = ''
    for i in S:
        if 97 <= ord(i) <= 122:
            if tmp:
                ans.append(int(tmp))
                tmp = ''
            else:
                tmp = ''
        else:
            tmp += i
    if tmp:
        ans.append(int(tmp))
ans.sort()
for i in ans:
    print(i)
cs

 

댓글