forked from Aigo-Oggi/mp-2023-pmi2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMNOG_MAS_19.c
76 lines (65 loc) · 1.9 KB
/
MNOG_MAS_19.c
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <stdio.h>
#include <stdlib.h>
void count_otsenki(int** A, int n, int m, int* neyavka, int* neud, int* ud, int* xor, int* otl) {
// Îáíóëÿåì ñ÷åò÷èêè îöåíîê
*neyavka = 0;
*neud = 0;
*ud = 0;
*xor = 0;
*otl = 0;
// Ñ÷èòàåì êîëè÷åñòâî îöåíîê äëÿ êàæäîãî ýêçàìåíà
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++)
{
if (A[i][j] == 1) {
(*neyavka)++;
}
else if (A[i][j] == 2) {
(*neud)++;
}
else if (A[i][j] == 3) {
(*ud)++;
}
else if (A[i][j] == 4) {
(* xor)++;
}
else if (A[i][j] == 5) {
(*otl)++;
}
}
}
}
int main() {
int n; // Êîëè÷åñòâî ñòóäåíòîâ
int m = 3; // Êîëè÷åñòâî ýêçàìåíîâ
printf("Enter the number of students: ");
scanf_s("%d", &n);
// Âûäåëÿåì ïàìÿòü ïîä ìàòðèöó îöåíîê
int** A = (int**)malloc(n * sizeof(int*));
for (int i = 0; i < n; i++) {
A[i] = (int*)malloc(m * sizeof(int));
}
// Ââîäèì îöåíêè èç êîíñîëè
for (int i = 0; i < n; i++) {
printf("Enter otsenku for student %d: ", i + 1);
for (int j = 0; j < m; j++) {
scanf_s("%d", &A[i][j]);
}
}
// Ïåðåìåííûå äëÿ õðàíåíèÿ êîëè÷åñòâà îöåíîê
int neyavka, neud, ud, xor, otl;
// Âûçûâàåì ôóíêöèþ äëÿ ïîäñ÷åòà îöåíîê
count_grades(A, n, m, &neyavka, &neud, &ud, &xor, &otl);
// Îñâîáîæäàåì âûäåëåííóþ ïàìÿòü
for (int i = 0; i < n; i++) {
free(A[i]);
}
free(A);
// Âûâîäèì ðåçóëüòàò
printf("Neyavka: %d\n", neyavka);
printf("Neudovletvoritelno: %d\n", neud);
printf("Udovletvoritelno: %d\n", ud);
printf("xorosho: %d\n", xor);
printf("Otlihno: %d\n", otl);
return 0;
}