Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     setlocale(LC_ALL, "ru");
  7.  
  8.     int count, row, col;
  9.  
  10.     cout << "введите кол-во строк" << endl;
  11.     cin >> row;
  12.  
  13.     cout << "введите кол-во столбцов" << endl;
  14.     cin >> col;
  15.  
  16.     int** arr = new int* [row];//массив указателей
  17.  
  18.     for (int i = 0; i < row; i++)
  19.     {
  20.         arr[i] = new int [col];
  21.     }
  22.  
  23.     for (int i = 0; i < row; i++)
  24.     {
  25.         for (int j = 0; j < col; j++)
  26.         {
  27.             cout << "введите эл массива в ячейке: [" << i << "; " << j << "]; ";
  28.             cin >> arr[i][j];
  29.         }
  30.  
  31.     }
  32.  
  33.     for (int i = 0; i < row; i++) // вывод массива
  34.     {
  35.         for (int j = 0; j < col; j++)
  36.         {
  37.             cout << arr[i][j] << "\t";
  38.         }
  39.         cout << endl;
  40.     }
  41.  
  42.     /////////////////////////
  43.     count = col * row;
  44.  
  45.     for (int i = 0; i < row*col; i++)
  46.     {
  47.         for (int j = i+1; j < row*col-1; j++)
  48.         {
  49.             if (*arr[i] == *arr[j])
  50.             {
  51.                 count--;
  52.             }
  53.         }
  54.     }
  55.  
  56.     cout << "количество"<<count;
  57.  
  58.     for (int i = 0; i < row; i++)// удаление массивов
  59.     {
  60.         delete[]arr[i];
  61.     }
  62.     delete[] arr;
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement