Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "ru");
- int count1 = 0, count2 = 0, count = 0, col, rowss, buf = 0;
- int i, j, c, r;
- cout << "введите кол-во строк";
- cin >> rowss;
- cout << "введите кол-во столбцов";
- cin >> col;
- int** arr = new int* [rowss];// создание массива указателей
- for (int i = 0; i < rowss; i++)
- {
- arr[i] = new int[col];
- }
- for (int i = 0; i < rowss; i++) //создание массивов
- {
- for (int j = 0; j < col; j++)
- {
- cout << "введите эл массива в ячейке: [" << i << "; " << j << "]; ";
- cin >> arr[i][j];
- }
- }
- for (int i = 0; i < rowss; i++) // вывод массива
- {
- for (int j = 0; j < col; j++)
- {
- cout << arr[i][j] << "\t";
- }
- cout << endl;
- }
- /////////////////////////////////////////////////
- cout << "1элемент массива под элементом 0\t" << *arr[0]<< endl;
- //////////////////////////////////////////////////////////////////
- for (int i = 0; i < rowss*col; i++)
- {
- for (int j = i+1; j < rowss*col-1; j++)
- {
- if (*arr[i] == *arr[j])
- {
- count1++;
- }
- else count2++;
- }
- }
- cout << "1: \t\t\t" << count1 << endl;
- cout << "2: \t\t\t" << count2 << endl;
- cout << "обычный: \t\t\t" << count1+count2 << endl;
- /*for (int i = 0; i < rowss; i++)
- {
- for (int j = 0; j < col; j++)
- {
- for (int r = 0; r != i, r < rowss; r++)
- {
- for (int c = 0; c != j, c < col; c++)
- {
- if (arr[i][j] == arr[r][c])
- {
- break;
- }
- else count++;
- }
- }
- }
- }*/
- //cout << "сумма: " << count << endl;
- ////////////////////////////////////////////////
- for (int i = 0; i < rowss; i++)// удаление массивов
- {
- delete[]arr[i];
- }
- delete[] arr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement