include stdio include stdlib include time int in_mass int int void sea

 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
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int** in_mass(int,int);
void search(int**,int,int);
int main()
{
srand ( time(NULL) );
int n, m;
int **a, **b;
int i,j;
printf("Input n: ");
scanf("%d",&n);
printf("Input m: ");
scanf("%d", &m);
printf("\tMatrix A\n");
a = in_mass(m,n);
printf("\n\tMatrix B\n");
b = in_mass(n,m);
printf("\nStrings A: ");
search(a,m,n);
printf("\nStrings B: ");
search(b,n,m);
return 0;
}
int** in_mass(int strok, int stolb)
{
int **mas;
int i,j;
mas = malloc(strok*sizeof(int*));
for(i=0; i < strok; i++){
mas[i] = malloc(stolb*sizeof(int));
for(j=0; j < stolb ; j++) {
mas[i][j] = rand()%100 * (rand()%2 ? -1 : 1);
printf("%d\t",mas[i][j]);
}
printf("\n");
}
return mas;
}
void search(int **mas,int str,int stolb)
{
int i, j, count=0;
for(i=0;i<str;i++){
for(j=0;j<stolb;j++){
if(mas[i][j]>0)
count++;
}
if(count == 2)
printf("%d ",i+1);
count = 0;
}
}