-
Notifications
You must be signed in to change notification settings - Fork 24
/
matrix №14
96 lines (85 loc) · 1.19 KB
/
matrix №14
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "stdio.h"
#include "time.h"
void Output_Array(int a[][5], int n, int m)
{
int i, j;
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
printf("%d ", a[i][j]);
}
printf("\n");
}
printf("\n");
}
void Input_Output_Array(int a[][5], int n, int m)
{
int i, j;
srand(time);
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
a[i][j] = rand() % 100;
}
}
Output_Array(a, n, m);
}
void MinEl(int a[][5], int n, int m)
{
int i, j;
int min;
int jmin = 0;
min = a[0][0];
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
if (a[i][j] < min)
{
min = a[i][j];
jmin = j;
}
}
}
printf("min = %d jmin = %d", min, jmin);
printf("\n");
printf("\n");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
a[i][jmin] = 0;
printf("%d ", a[i][j]);
}
printf("\n");
}
printf("\n");
}
void Delete(int a[][5], int n, int m)
{
int i, j;
int jmin;
int b[10][10];
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
if (a[i][j] != 0)
{
b[i][j] = a[i][j];
printf("%d ", b[i][j]);
}
}
printf("\n");
}
}
void main()
{
int a[5][5];
int n = 5, m = 5;
Input_Output_Array(a, n, m);
MinEl(a, n, m);
Delete(a, n, m);
}