광고
광고
반응형
[ 문제 ]
난이도: D2
문제 번호: 1984
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
10개의 수를 입력 받아, 최대 수와 최소 수를 제외한 나머지의 평균값을 출력하는 프로그램을 작성하라.
(소수점 첫째 자리에서 반올림한 정수를 출력한다.)
[제약 사항]
각 수는 0 이상 10000 이하의 정수이다.
[ 코드 ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
for tc in range(1, int(input())+1):
numbers = list(map(int, input().split()))
max_num = 0
min_num = 987654321
for number in numbers:
if number > max_num:
max_num = number
if number < min_num:
min_num = number
total = 0
for number in numbers:
if number == max_num or number == min_num:
total += 0
else:
total += number
print('#{} {}'.format(tc, round(total/(len(numbers)-2))))
|
cs |
반응형
'SW Expert' 카테고리의 다른 글
[SWEA] 1986 지그재그 숫자 Python (0) | 2021.05.28 |
---|---|
[SWEA] 1983 조교의 성적 매기기 Python (0) | 2021.05.26 |
[SWEA] 1979 어디에 단어가 들어갈 수 있을까 Python (0) | 2021.05.25 |
[SWEA] 1976 시각 덧셈 Python (0) | 2021.05.24 |
[SWEA] 1974 스도쿠 검증 Python (0) | 2021.05.24 |