#include "stdafx.h"
#include <iostream>
using namespace std;
int N;
int main() {
setlocale(0, "");
cout << "Введите размер матрицы: ";
cin >> N;
int ** A = new int *[N];
for (int i = 0; i < N; i++)
A[i] = new int[N];
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
A[i][j] = ((rand() % 10));
cout << "Сгенерированная матрица: " << endl << endl;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
cout << A[i][j] << " ";
cout << endl;
}
cout << endl;
int reps = 0;
int i, j;
int inext, jnext;
int temp;
i = 0; j = 0;
for (inext = 0; inext < N; inext++){
for (jnext = (inext ? 0 : 1); jnext < N; jnext++)
{
if (A[i][j] == A[inext][jnext]){
reps++;
continue;
}
cout << A[i][j] << " : " << reps + 1 << endl;
reps = 0;
i = inext;
j = jnext;
}
}
cin.get();
cin.get();
return 0;
}