Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void ManualDelete(int**& arr, int& hight, int width)
- {
- int counter = 0;
- for(int i = 0; i < hight; i++)
- {
- int mini_counter = 0;
- for(int j = 0; j < width; j++)
- {
- if(arr[i][j]%2 == 0) mini_counter++;
- }
- if(mini_counter > 3)
- counter++;
- }
- int** temp = new int*[hight-counter];
- for(int i = 0, c = 0; i < hight; i++)
- {
- int mini_counter = 0;
- for(int j = 0; j < width; j++)
- {
- if(arr[i][j]%2==0) mini_counter++;
- }
- if(mini_counter <= 3)
- {
- temp[c] = arr[i];
- c++;
- }
- }
- delete[] arr;
- arr = temp;
- hight -= counter;
- }
- void init(int**& arr, int hight, int width)
- {
- arr = new int*[hight];
- for(int i = 0; i < hight; i++)
- {
- arr[i] = new int[width];
- for(int j = 0; j < width; j++)
- {
- arr[i][j] = rand()%100;
- }
- }
- }
- void show(int** arr, int height, int width)
- {
- for(int i = 0; i < height; i++)
- {
- for(int j = 0; j < width; j++)
- {
- cout << arr[i][j] << " ";
- }
- cout << endl;
- }
- }
- int main()
- {
- int hight = 5;
- int width = 5;
- int** array = nullptr;
- init(array, hight, width);
- show(array, hight, width);
- cout << endl;
- ManualDelete(array, hight, width);
- cout << endl;
- show(array, hight, width);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement