(I was able to solve the previous problem with the output of the array, everything worked out).
I have here a piece of code for which I would like to write a function to shorten the code. But I don't know how to do it, since, apparently, it would need to return two values and I do not know how to do it...
Or should I break this action into two different functions?
Or it is better to leave the code in this form?
int a2x = 0;
int m2x = 0;
for (i = 0; i < n; i++) {
if (x[i] > 0) {
a2x = a2x + x[i];
}
if (x[i] < 0) {
m2x++;
}
}
printf("\n");
printf("a2x %5d \n", a2x);
printf("m2x %5d \n", m2x);
int a2y = 0, m2y = 0;
for (j = 0; j < m; j++) {
if (y[j] > 0) {
a2y = a2y + y[j];
}
if (y[j] < 0) {
m2y++;
}
}
printf("a2y %5d \n", a2y);
printf("m2y %5d \n",m2y);