-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymmetricMatrix.cpp
41 lines (32 loc) · 1.01 KB
/
symmetricMatrix.cpp
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
//
// Created by guilherme on 08/06/18.
//
#include <iostream>
using namespace std;
void FillMatrix( int **matrix, int lines, int columns ){
for(int lin=0; lin<lines; lin++)
for(int col=0; col<columns; col++)
cin >> matrix[lin][col];
}
bool IsSymmetric( int **matrix, int lines, int columns ){
for(int lin=0; lin<lines; lin++)
for(int col=0; col<columns; col++)
if( matrix[lin][col] == matrix[col][lin] ) return true;
}
int main(){
int lines=0, columns=0;
int **matrix = nullptr;
// Fill Matrix
cout << "Input the number of lines of the matrix:" << endl;
cin >> lines;
cout << "Input the number of columns of the matrix:" << endl;
cin >> columns;
matrix = new int*[lines];
for(int lin=0; lin<lines; lin++)
matrix[lin] = new int[columns];
FillMatrix( matrix, lines, columns );
// Verification
if( IsSymmetric(matrix, lines, columns) ) cout << "IS SYMMETRIC" << endl;
else cout << "IS NOT SYMMETRIC";
return 0;
}