Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- static int li = -1, lj = -1;// lenght
- void setZero(int** arr, int &i, int &j) {
- if (i >= li || j >= lj)
- return;
- if (arr[i][j] % 2 == 0)
- arr[i][j] = 0;
- if (j == lj - 1) {
- j = 0;
- i++;
- }
- else
- {
- j++;
- }
- setZero(arr, i, j);
- }
- int main() {
- while (li < 1 || lj < 1) {
- cout << "Enter the row and collum count: ";
- cin >> li >> lj;
- }
- cout << "Enter the array: " << endl;
- int iD = 0, jD = 0;
- int** arr = new int* [li];
- for (int i = 0; i < li; i++) {
- arr[i] = new int[lj];
- for (int j = 0; j < lj; j++) {
- cin >> arr[i][j];
- }
- }
- setZero(arr, iD, jD);
- cout << "Result array: " << endl;
- for (int i = 0; i < li; i++) {
- for (int j = 0; j < lj; j++) {
- cout << arr[i][j] << " ";
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment