Skip to content

Instantly share code, notes, and snippets.

@glowing713
Created July 18, 2019 11:06
Show Gist options
  • Save glowing713/a9d955ab29f86ec5ecb2e2e799dbf6f5 to your computer and use it in GitHub Desktop.
Save glowing713/a9d955ab29f86ec5ecb2e2e799dbf6f5 to your computer and use it in GitHub Desktop.
백준 1546번 평균
#include <iostream>
using namespace std;
int main(void){
const int SIZE = 1000;
int num = 0, max = 0;
double sum = 0;
int arr[SIZE] = {0,};
cin >> num;
for(int i = 0; i < num; i++){
cin >> arr[i];
}
for(int j = 0; j < num; j++){
if(arr[j] > max) max = arr[j];
}
for(int k = 0; k < num; k++){
sum += ((double)arr[k]/max)*100;
}
printf("%.2f\n", sum/num);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment