fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int a, b;
  6. cout<<"Enter First Matrix Size: ";
  7. cin>>a>>b;
  8. int matrix1[a][b];
  9. cout<<"Enter First Matrix Element: "<<endl;
  10. for(int i=0; i<a; i++){
  11. for(int j=0; j<b; j++)
  12. {
  13. cin>>matrix1[i][j];
  14. }
  15. }
  16.  
  17. int a1, b1;
  18. cout<<"Enter Second Matrix Size: ";
  19. cin>>a1>>b1;
  20. int matrix11[a][b];
  21. cout<<"Enter Second Matrix Element: "<<endl;
  22. for(int i=0; i<a; i++){
  23. for(int j=0; j<b; j++)
  24. {
  25. cin>>matrix11[i][j];
  26. }
  27. }
  28.  
  29. int flag = 0;
  30. for(int i=0; i<a; i++){
  31. for(int j=0; j<b; j++)
  32. {
  33. if(matrix1[i][j] != matrix11[i][j])
  34. {
  35. flag = 1;
  36. }
  37. }
  38. }
  39.  
  40.  
  41. if(flag == 0)
  42. {
  43. cout<<"The two matrix are equal"<<endl;
  44. }else
  45. {
  46. cout<<"The two matrix are not equal"<<endl;
  47. }
  48.  
  49. return 0;
  50. }
  51.  
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
Enter First Matrix Size: Enter First Matrix Element: 
Enter Second Matrix Size: Enter Second Matrix Element: 
The two matrix are equal