-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab11.c
54 lines (48 loc) · 1022 Bytes
/
lab11.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
#include<stdio.h>
#include <time.h>
#include<stdlib.h>
int kr_5(int **array)
{
int i, j,k=0;
for (i = 0; i < 5; i++)
for (j = 0; j < 5; j++)
if (array[i][j] % 5 == 0 && array[i][j]!=0)
k++;
return (k);
}
int main()
{
int **a=NULL,i,j;
a = (int **)malloc(5 * sizeof(int *));
if (!(a))
{
printf("Error!\n");
exit(EXIT_FAILURE);
}
//Создание массива указателей столбцов
for (i = 0; i < 5; i++)
{
a[i] = (int *)malloc(5 * sizeof(int));
if (!(a[i]))
{
printf("Error!\n");
exit(EXIT_FAILURE);
}
}
for (i = 0; i < 5; i++)
{
for (j = 0; j < 5; j++)
{
a[i][j] = rand() % 10;
}
}
for (i = 0; i < 5; i++)
{
for (j = 0; j < 5; j++)
{
printf("%2d", a[i][j]);
}
printf("\n");
}
printf("Kol-vo elementov kratnih 5: %d\n", kr_5(a));
}