检查两个矩阵是否相同的 C# 程序
if (row1 != row2 && col1 != col2) { Console.Write("Matrices can't be compared:"); }
现在,在 else 条件下检查指标是否相同。我们还在这里设置了一个标志 -
if (row1 != row2 && col1 != col2) { Console.Write("Matrices can't be compared:"); } else { Console.Write("Comparison of Matrices: "); for (i = 0; i < row1; i++) { for (j = 0; j < col2; j++) { if (arr1[i, j] != arr2[i, j]) { flag = 0; break; } } } if (flag == 1) Console.Write("Our matrices are equal!"); else Console.Write("Our matrices are not equal!"); }登录后复制