Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     setlocale(LC_ALL, "Russian");
  8.     int n, m;
  9.     cout << "Сколько строк?" << endl;
  10.     cin >> n;
  11.     cout << "Сколько столбцов?" << endl;
  12.     cin >> m;
  13.  
  14.     int **arr = new int *[n];
  15.     for (int i = 0; i < n; i++)
  16.         arr[i] = new int[m];
  17.  
  18.     for (int i = 0; i < n; i++)
  19.         for (int j = 0; j < m; j++)
  20.             cin >> arr[i][j];
  21.    
  22.     for (int i = n - 1; i >= 0; i--)
  23.     {
  24.         bool check = true;
  25.         for (int j = 0; j < m; j++)
  26.             if (arr[i][j] % 2 == 0)
  27.             {
  28.                 check = false;
  29.                 break;
  30.             }
  31.  
  32.         if (check)
  33.         {
  34.             for (int k = i; k + 1 < n; k++)
  35.                 for (int j = 0; j < m; j++)
  36.                 {
  37.                     arr[k][j] = arr[k + 1][j];
  38.                 }
  39.             delete[]arr[n - 1];
  40.             n--;
  41.         }
  42.     }
  43.  
  44.     cout << endl;
  45.     for (int i = 0; i < n; i++, cout << endl)
  46.         for (int j = 0; j < m; j++)
  47.             cout << arr[i][j] << " ";
  48.  
  49.     for (int i = 0; i < n; i++)
  50.         delete[]arr[i];
  51.     delete[]arr;
  52.  
  53.     system("pause");
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement