머가 잘못 된건가용..ㅠㅠ
한지잠
#include stdio.h
#define max_stdt 5
#define max_sbjt 3
int main()
{
int i,j, tot, score[max_stdt][max_sbjt];
float avg;
int rank[5];
printf(enter the score...\n);
for (i=0; imax_stdt; i++)
{
printf(%d: \n, i+1);
scanf(%d %d %d, &score[i][0], &score[i][1], &score[i][2]);
}
printf(no kor eng math tot avg grade\n);
for (i=0; imax_stdt; i++)
{
tot = score[i][0] + score[i][1] + score[i][2];
avg=(float)tot/max_sbjt;
}
for(i=0; i5; i++)
{
rank[i]=1;
for(j=0; j5; j++)
{
if(avg avg)rank[j]++;
}
printf(%d : %3d %3d %3d %3d %3.2f %d\n, i, score[i][0], score[i][1], score[i][2], tot, avg, rank[i]);}
return 0;
}
ㅠㅠ 잘나오던 tot,avg값도 안나오궁..ㅠㅠ 석차는 무조건 1만 나오궁 머가 잘못된건가용?ㅠ
-
새우깡 2023-06-18
석차까지 하시려면
tot avg를 배열로 넣으셔서
비교하시는게 나을듯 싶네요.... -
가막새 2023-06-18
일단... tot avg값이 안나오는 이유는....
for (i=0; imax_stdt; i++)
{
tot = score[i][0] + score[i][1] + score[i][2];
avg=(float)tot/max_sbjt;
}
이포문에서 계속 값이 삭제되고 있기때문입니다.
그래서 결국 tot avg값은 계속 바껴서 맨마지막 값을 갖습니다.