백준 알고리즘(C/C++) - 1546번 평균
- 알고리즘
- 2021. 6. 7.
int main(void) {
int i = 0, n, m = 0;
float s = 0;
scanf("%d", &n);
int a[n];
for (; i < n; i++) {
scanf("%d", &a[i]);
if (m < a[i]) m = a[i];
s += a[i];
}
printf("%f", (s / m * 100) / n);
}
#include <iostream>
int main() {
int i = 0, n, m = 0;
float s = 0;
std::cin >> n;
int a[n];
for (; i < n; i++) {
std::cin >> a[i];
if (m < a[i])m = a[i];
s += a[i];
}
std::cout << (s / m * 100) / n;
}