백준/기초

[백준][1차원 배열] 1546번 평균

Snowboarder 2022. 3. 10. 21:38

문제접근

  • 1차원 배열
  • for i in list:

문제풀이

내풀이

n = int(input())  # 과목 수
test_list = list(map(int, input().split()))
max_score = max(test_list)

new_list = []
for score in test_list :
    new_list.append(score/max_score *100)  # 새로운 점수 생성
test_avg = sum(new_list)/n
print(test_avg)

다른사람풀이

# 1546
n = int(input())
a=list(map(int,input().split()))
m = max(a)
for i in range(n):
    a[i] = a[i]/m*100
print(sum(a)/n)
  • for i in range를 써서 그 리스트 값을 다 초기화 해줌

숏코딩

n,*l=map(int,open(0).read().split())
print(sum(l)*100/max(l)/n)