Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.87 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     setlocale(LC_ALL, "ru");
  7.  
  8.     int count1 = 0, count2 = 0, count = 0, col, rowss, buf = 0;
  9.     int i, j, c, r;
  10.  
  11.     cout << "введите кол-во строк";
  12.     cin >> rowss;
  13.     cout << "введите кол-во столбцов";
  14.     cin >> col;
  15.  
  16.     int** arr = new int* [rowss];// создание массива указателей
  17.  
  18.     for (int i = 0; i < rowss; i++)
  19.     {
  20.         arr[i] = new int[col];
  21.     }
  22.  
  23.  
  24.     for (int i = 0; i < rowss; i++) //создание массивов
  25.     {
  26.         for (int j = 0; j < col; j++)
  27.         {
  28.             cout << "введите эл массива в ячейке: [" << i << "; " << j << "]; ";
  29.             cin >> arr[i][j];
  30.         }
  31.  
  32.     }
  33.  
  34.  
  35.     for (int i = 0; i < rowss; i++) // вывод массива
  36.     {
  37.         for (int j = 0; j < col; j++)
  38.         {
  39.             cout << arr[i][j] << "\t";
  40.         }
  41.         cout << endl;
  42.     }
  43.     /////////////////////////////////////////////////
  44.  
  45.     cout << "1элемент массива под элементом 0\t" << *arr[0]<< endl;
  46. //////////////////////////////////////////////////////////////////
  47.  
  48.     for (int i = 0; i < rowss*col; i++)
  49.     {
  50.         for (int j = i+1; j < rowss*col-1; j++)
  51.         {
  52.             if (*arr[i] == *arr[j])
  53.             {
  54.                 count1++;
  55.             }
  56.             else count2++;
  57.         }
  58.     }
  59.  
  60.     cout << "1: \t\t\t" << count1 << endl;
  61.     cout << "2: \t\t\t" << count2 << endl;
  62.     cout << "обычный: \t\t\t" << count1+count2 << endl;
  63.  
  64.     /*for (int i = 0; i < rowss; i++)
  65.     {
  66.         for (int j = 0; j < col; j++)
  67.         {
  68.             for (int r = 0; r != i, r < rowss; r++)
  69.             {
  70.                 for (int c = 0; c != j, c < col; c++)
  71.                 {
  72.                     if (arr[i][j] == arr[r][c])
  73.                     {
  74.                         break;
  75.                     }
  76.                     else count++;
  77.                 }
  78.  
  79.             }
  80.  
  81.         }
  82.     }*/
  83.     //cout << "сумма: " << count << endl;
  84.     ////////////////////////////////////////////////
  85.  
  86.     for (int i = 0; i < rowss; i++)// удаление массивов
  87.     {
  88.         delete[]arr[i];
  89.     }
  90.     delete[] arr;
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement