1546번 - 평균
#include
#define _CRT_SECURE_NO_WARNINGS
int main(void) {
long a;
double b = 0;
double c;
int count[100] = { 0 };
int max = 0;
scanf("%d", &a);
for (int i = 0; i < a; i++)
{
scanf("%d", &count[i]);
}
if (count[i] > max)
max = count[i];
b += (double)count[i] / max * 100;
c = b / a;
printf("%lf", c);
return 0;
}런타임 오류라고 뜨는데 모르겠어요
과목의 개수는 최대 1000입니다.
댓글을 작성하려면 로그인해야 합니다.
ojunghui1234 2년 전
#include
#define _CRT_SECURE_NO_WARNINGS
int main(void) {
long a;
double b = 0;
double c;
int count[100] = { 0 };
int max = 0;
scanf("%d", &a);
for (int i = 0; i < a; i++)
{
scanf("%d", &count[i]);
}
for (int i = 0; i < a; i++)
{
if (count[i] > max)
{
max = count[i];
}
}
for (int i = 0; i < a; i++)
{
b += (double)count[i] / max * 100;
}
c = b / a;
printf("%lf", c);
return 0;
}
런타임 오류라고 뜨는데 모르겠어요