include iostream include cstdlib include ctime using namespace std voi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void srav(int **arr, int N){
for (int i = 0; i <N; i++)
for (int j = 0; j <N; j++)
if (arr[i][j]!=0) {
for (int k=0; k <N; k++) {
arr[i][k]=0;
arr[k][i]=0;
arr[j][k]=0;
arr[k][j]=0;
}
cout<<i<<" "<<j+1<<endl;
}
}
int** create(int N) {
//Creating
srand(time(0));
int **arr = new int*[N];
for(int i=0; i<N; i++) {
arr[i] = new int[N];
for(int j = 0; j<N; j++)
arr[i][j] = rand()%100;
}
return arr;
}
void freemem(int** arr, int N) {
for(int i=0; i<N; i++)
delete[] arr[i];
}
void show(int** arr, int N) {
//Show
for(int i=0; i<N; i++) {
for(int j = 0; j<N; j++)
cout<<arr[i][j]<<" ";
cout<<endl;
}
}
int main()
{
int **arr = create(10);
show(arr, 10);
srav(arr, 10);
freemem(arr,10);
return 0;
}