ÇÑ ÇлýÀÇ 4°ú¸ñ Á¡¼ö¸¦ Æò±Õ³»¾î ¸®ÅÏÇÏ´Â ¿¹
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #define NUM_STUDENTS 3 #define NUM_SUBJECTS 4 double avg_score(int jumsu[], int num) { int i, sum = 0; for (i = 0; i < num; i++) { sum += jumsu[i]; } return (double)sum / num; } int main(void) { int i, scores[NUM_STUDENTS][NUM_SUBJECTS] = { {98, 50, 33, 60}, {86, 80, 99, 40}, {45, 67, 30, 90} }; double average; for (i = 0; i < NUM_STUDENTS; i++) { average = avg_score(scores[i], NUM_SUBJECTS); printf("%d ÇлýÀÇ 4°ú¸ñÀÇ Æò±ÕÀº %lf ÀÔ´Ï´Ù.\n", i + 1, average); } } | cs |