#include <iostream.h>
#include <conio.h>
int numzeros(int a[ ][4][3], int n1, int n2, int n3);
void main( )
{
int a[2][4][3]={ { {5,0,2}, {0,0,9}, {4,1,0}, {7,7,7}},
{ {3,0,0}, {8,5,0}, {0,0,0}, {2,0,9}}
};
cout<<"This Array has "<<numzeros(a,2,4,3)<<" zeros. \n";
getch( );
}
int numzeros (int a[ ][4][3], int n1, int n2, int n3)
{
int count = 0;
for (int i = 0; i < n1; i++)
for (int j= 0; j < n2; j++)
for (int k = 0; k < n3; k++)
if (a[i][j][k] == 0) ++count;
return count;
}
0 comments:
Post a Comment