void avg_score(int a[][4],int total,int avg) {

for (int i = 0; i < 5; i++) {

a[i][3] = a[i][2]/2;

}

//avg = (a[0][3] + a[1][3] +a[2][3] + a[3][3] + a[4][3]) / 5;        <<<이부분

}



void main(void)

{

int score[5][4];            <<<<<<<< score 배열 아래 total변수와 avg변수를 함수에 돌렸는데 score배열은 값을 잘받는데

int total = 0, avg = 0;        <<<<<<<<  avg 변수는 여기 초기화한대로 그대로 0으로 출력됨

for (int i = 0; i < 5; i++)

score[i][2] = 0;

insert_score(score);

total_score(score,total);

avg_score(score,total,avg);

for (int i = 0; i < 5; i++) {

total = total + score[i][2];

}

printf("번호 중간 기말 총점 평균\n");

for (int i = 0; i <5; i++) {

printf("%d번 ", i + 1);

printf("%d ",score[i][0]);

printf("%d ", score[i][1]);

printf("%d ", score[i][2]);

printf("%d\n", score[i][3]);

}

printf("총점 : %d\n", total);

printf("평균 : %d\n", avg = (score[0][3] + score[1][3] + score[2][3] + score[3][3] + score[4][3]) / 5); //


system("pause");



}




중간부분만 올렸습니다.


내용은 배열 입력받고 입력받은 값을 토대로 평균 구하고 총점 구하는것인데

같은 함수에 넣은 배열값은 변경이 잘됨니다 그런데 그냥 변수는 값이 변경 되질않습니다.


메인함수에서 변수를 0으로  초기화 했는데 그대로 나와요;;


원래 함수에서 변수받아서 변경하는건 안되나요??