include stdio include stdlib define define define int findMin int mas

 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
#include <stdio.h>
#include <stdlib.h>
#define N 2
#define M 2
#define L 4
int findMin(int *mas, int size){
int i, min=9999; // min условно равно бесконечности
for(i=0; i<size; i++){
if(mas[i] > 0 && min > mas[i])
min = mas[i];
}
if(min != 9999)
return min;
else
return -1;
}
void input_mas(int *mas, int size){
int i;
for(i=0; i<size; i++){
scanf("%d", &mas[i]);
}
}
int main(){
int X[N][M], Y[L];
int minX, minY;
double S;
printf("Input matrix X: \n");
input_mas(&X[0][0], N*M);
printf("Input massive Y: \n");
input_mas(Y, L);
if((minX=findMin(&X[0][0], N*M)) == -1 || (minY=findMin(Y, L)) == -1){
printf("Invalid one of the massive.\n There are no positive elements. \n");
}
S=(double)minX/minY;
printf("S = %lf\n", S);
return 0;
}