-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnomogram.c
70 lines (64 loc) · 1.26 KB
/
nomogram.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
// Copyright 2021-2022 313CA Ciocoiu Diana Iulia
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int T, B, n, m, a, nr_corpuri, sp;
int s_linii[100], s_coloane[100], puzzle[100][100];
sp = 0;
scanf("%d", &T);
while (T > 0) {
//B = 1 (Corect)
B = 1;
scanf("%d %d", &n, &m);
//calculez suma el. pe fiecare linie
for (int i = 0; i < n; i++) {
s_linii[i] = 0;
scanf("%d", &nr_corpuri);
for (int j = 0; j < nr_corpuri; j++) {
scanf("%d", &a);
s_linii[i] += a;
}
}
//calculez suma el. pe fiecare linie
for (int i = 0; i < m; i++) {
s_coloane[i] = 0;
scanf("%d", &nr_corpuri);
for (int j = 0; j < nr_corpuri; j++) {
scanf("%d", &a);
s_coloane[i] += a;
}
}
//citesc puzzle-ul
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++)
scanf("%d", &puzzle[i][j]);
}
for (int i = 0; i < n; i++) {
sp = 0;
for (int j = 0; j < m; j++)
sp += puzzle[i][j];
if (sp != s_linii[i]) {
//B = 1 (Eroare)
B = 0;
break;
}
}
for (int i = 0; i < m; i++) {
sp = 0;
for (int j = 0; j < n ; j++)
sp += puzzle[j][i];
if (sp != s_coloane[i]) {
//B = 1 (Eroare)
B = 0;
break;
}
}
if (B == 1)
printf("Corect\n");
else
printf("Eroare\n");
T--;
}
return 0;
}