Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Дан двухмерный массив размерностью 3×4.
- Необхо- димо найти количество элементов значение которых равно нулю.*/
- #include <iostream>
- #include <time.h>
- using namespace std;
- int main()
- {
- srand(time(nullptr));
- const int ROW = 3;
- const int COL = 4;
- int Array[ROW][COL];
- int save = 0;
- for (int i = 0; i < ROW; i++)
- {
- for (int j = 0; j < COL; j++)
- {
- Array[i][j] = rand() % 10;
- }
- }
- for (int i = 0; i < ROW; i++)
- {
- for (int j = 0; j < COL; j++)
- {
- if (Array[i][j] == 0)
- {
- save++;
- }
- cout << Array[i][j] << ' ';
- }
- cout << endl;
- }
- if (save >= 1)
- {
- cout << "The number of zeros in the array " << save << endl;
- }
- else
- {
- cout << "No zeros in the array " << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement