C程序比较两个矩阵是否相等
用户必须输入两个矩阵的顺序和两个矩阵的元素。然后,比较这两个矩阵。
如果矩阵元素和大小都相等,则显示两个矩阵相等。
如果矩阵的大小相等但元素不相等,则显示矩阵可以比较但不相等。
如果大小和元素不匹配,则显示无法比较矩阵。
程序
以下是比较两个矩阵是否相等的C程序-
#include#include main(){ int A[10][10], B[10][10]; int i, j, R1, C1, R2, C2, flag =1; printf("Enter the order of the matrix A\n"); scanf("%d %d", &R1, &C1); printf("Enter the order of the matrix B\n"); scanf("%d %d", &R2,&C2); printf("Enter the elements of matrix A\n"); for(i=0; i 输出结果 执行上述程序时,会产生以下结果-
Run 1: Enter the order of the matrix A 2 2 Enter the order of the matrix B 2 2 Enter the elements of matrix A 1 2 3 4 Enter the elements of matrix B 1 2 3 4 MATRIX A is 1 2 3 4 MATRIX B is 1 2 3 4 Matrices can be compared Two matrices are equal Run 2: Enter the order of the matrix A 2 2 Enter the order of the matrix B 2 2 Enter the elements of matrix A 1 2 3 4 Enter the elements of matrix B 5 6 7 8 MATRIX A is 1 2 3 4 MATRIX B is 5 6 7 8 Matrices can be compared But,two matrices are not equal
热门推荐
10 香港老妈结婚祝福语简短
11 毕业立体贺卡祝福语简短
12 简短新年年会祝福语
13 评论小品祝福语大全简短
14 恭喜师兄结婚祝福语简短
15 员工集体辞职祝福语简短
16 高中新生祝福语 简短
17 装修祝福语男生搞笑简短
18 生日开业蛋糕祝福语简短