9511_workbook

solved exercises from algorithms & programming I (9511) prof. Cardozo
Index Commits Files Refs README
commit fd30e4db95b63e0e176e9f6e70291b1ad8fcfa44
parent b45e895d5ac7c1df20b94a8a607f26ec3969c33d
Author: klewer-martin <martin.cachari@gmail.com>
Date:   Thu,  1 Apr 2021 19:03:57 -0300

Update: ex47.c done

Diffstat:
Mguia03/ex47.c | 25+++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/guia03/ex47.c b/guia03/ex47.c
@@ -4,13 +4,15 @@
 #include <time.h>
 
 #define N 3
-#define M 4
+#define M 3
 
 void m_load(size_t r, size_t c, double matrix[r][c]);
 void m_initrand(size_t r, size_t c, double matrix[r][c]);
 void m_print(size_t r, size_t c, double matrix[r][c]);
 void m_transpose(size_t r, size_t c, double matrix[r][c], double matrix_t[c][r]);
-bool m_simetric(size_t r, size_t c, double matrix[r][c]);
+
+bool m_isSimetric(size_t r, size_t c, double matrix[r][c]);
+
 
 int main (void)
 {
@@ -24,6 +26,7 @@ int main (void)
     m_transpose(N, M, matrix, matrix_transpose);
     m_print(M, N, matrix_transpose);
 
+    printf("\nThe matrix is %s SIMETRIC.", m_isSimetric(N, M, matrix) ? "" : "NOT");
 
     return 0;
 }
@@ -71,3 +74,21 @@ void m_transpose(size_t r, size_t c, double matrix[r][c], double matrix_t[c][r])
 
     }
 }
+
+bool m_isSimetric(size_t r, size_t c, double matrix[r][c])
+{
+    double matrix_transpose[r][c];
+    m_transpose(r, c, matrix, matrix_transpose);
+
+    size_t aux = 0;
+    for(size_t i = 0; i < r; i++)
+        for(size_t j = 0; j < c; j++)
+            if(matrix[i][j] == matrix_transpose[i][j])
+                aux++;
+
+    //if(aux == (r * c))
+    //    return true;
+
+    //return false;
+    return true * (aux == (r * c)) + false * (aux != (r * c));
+}