int ZerosInArray(int a[], int n) { int k; for (int i = 0; i < n; i++)if (a[i] == 0) k++; return k; }
int main() { int N = 10; int a[N]; int k; srand(time(NULL)); for (int i = 0; i < N; i++) { a[i] = rand() % 5 - 3; printf("%d ", a[i]); } k = ZerosInArray(a, N); printf("%s%d", "\nZeros = ", k); return 0; }
0 votes Thanks 0
miaxx
Что означает int ZerosInArray(int a[], int n)?
Answers & Comments
#include <time.h>
int ZerosInArray(int a[], int n)
{
int k;
for (int i = 0; i < n; i++)if (a[i] == 0) k++;
return k;
}
int main()
{
int N = 10;
int a[N];
int k;
srand(time(NULL));
for (int i = 0; i < N; i++)
{
a[i] = rand() % 5 - 3;
printf("%d ", a[i]);
}
k = ZerosInArray(a, N);
printf("%s%d", "\nZeros = ", k);
return 0;
}