[Python] 백준 1546번 평균★VER3.0★FOR문 사용하지 않기
2023. 3. 27. 17:07
728x90
반응형
VER3.0
import sys
N = int(sys.stdin.readline())
score = list(map(int, sys.stdin.readline().split()))
maxe = max(score)
avg = 0
for i in score:
avg += i/maxe *100
print(avg/N)
VER 2.0
import sys
import itertools
a = int(sys.stdin.readline())
b = list(map(int, sys.stdin.readline().rstrip().split(' ')))
chng = max(b)
all , res = 0 ,0
res = (sum(b) /chng*100) / len(b)
print(res)
==> FOR문 사용하지 않고도 구할 수 있다!
VER 1.0
import sys
N = int(sys.stdin.readline())
while True:
A = list(map(int, sys.stdin.readline().split()))
if len(A)==N :
break
maxe = max(A)
sum , avg = 0 , 0
for i in A:
sum+= i/maxe*100
avg = sum/N
print("%f" % avg)
728x90
반응형
'Python(백준) > 배열' 카테고리의 다른 글
★2중 리스트★[Python 백준 10813번 공 바꾸기] (0) | 2023.03.27 |
---|---|
★FOR문★[Python 백준 10810번 공넣기] (0) | 2023.03.27 |
★VER2.0★max()안쓰고 구하기★[백준 파이썬 2562번 최대] (0) | 2023.03.27 |
★VER 2.0★min,max★1차원 배열 최소 최대숫자 알아보기 [백준 Python 10818번] (0) | 2023.03.27 |
[백준 파이썬 11003번]최솟값 찾기★VER2.0★시간초과 고려 (0) | 2022.12.29 |