Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. //void MatrizIndentidad()
  7. //{
  8. //
  9. // int Matriz_I[12][12];
  10. //
  11. // for (int fila = 0; fila < 12; fila++)
  12. // {
  13. // for (int columna = 0; columna < 12; columna++)
  14. // {
  15. // if (fila == columna)
  16. // Matriz_I[fila][columna] = 1;
  17. // else
  18. // Matriz_I[fila][columna] = 0;
  19. //
  20. // cout << Matriz_I[fila][columna];
  21. // }
  22. // cout << endl;
  23. // }
  24. //}
  25.  
  26. //void MatrizA( int m[][12], int _n, int _n2)
  27. //{
  28. //
  29. // srand(time(NULL));
  30. // int Matriz_A[12][12];
  31. //
  32. // for (int fila = 0; fila < _n; fila++)
  33. // {
  34. // for (int columna = 0; columna < 12; columna++)
  35. // {
  36. // Matriz_A[fila][columna] = rand() % 10 + 1;
  37. //
  38. // cout << Matriz_A[fila][columna] << " ";
  39. // }
  40. //
  41. // cout << endl;
  42. // }
  43. //
  44. //}
  45.  
  46. //void MatrizB()
  47. //{
  48. // srand(time(NULL));
  49. // int Matriz_B[12];
  50. //
  51. // for (int fila = 0; fila < 12; fila++)
  52. // {
  53. // Matriz_B[fila] = rand() % 50 + 10;
  54. //
  55. // cout << Matriz_B[fila] << endl;
  56. // }
  57. //}
  58.  
  59. void main()
  60. {
  61. srand(time(NULL));
  62.  
  63.  
  64.  
  65. int n;
  66. do {
  67. cout << "Ingresa el tama" << char(164) << "o de las matrices: ";
  68. cin >> n;
  69.  
  70. } while (n < 2 || n > 12);
  71.  
  72. int C[12][12];
  73. for (int fila = 0; fila < n; fila++)
  74. for (int columna = 0; columna < n; columna++)
  75. C[fila][columna] = 0;
  76.  
  77. int Matriz_A[12][12];
  78. for (int fila = 0; fila < n; fila++)
  79. {
  80. for (int columna = 0; columna < n; columna++)
  81. {
  82. Matriz_A[fila][columna] = rand() % 10 + 10;
  83.  
  84. cout << Matriz_A[fila][columna] << " ";
  85. }
  86.  
  87. cout << endl;
  88. }
  89.  
  90.  
  91. int Matriz_I[12][12];
  92. for (int fila = 0; fila < n; fila++)
  93. {
  94. for (int columna = 0; columna < n; columna++)
  95. {
  96. if (fila == columna)
  97. Matriz_I[fila][columna] = 1;
  98. else
  99. Matriz_I[fila][columna] = 0;
  100.  
  101. cout << Matriz_I[fila][columna];
  102. }
  103. cout << endl;
  104. }
  105.  
  106.  
  107. int Matriz_B[12];
  108. for (int fila = 0; fila < n; fila++)
  109. {
  110. Matriz_B[fila] = rand() % 10 + 10;
  111.  
  112. cout << Matriz_B[fila] << endl;
  113. }
  114.  
  115.  
  116.  
  117. for (int i = 0; i < n; i++)
  118. {
  119. for (int j = 0; j < n; j++)
  120. {
  121. for (int z = 0; z < n; z++)
  122. {
  123. C[i][j] += Matriz_A[i][z] * Matriz_I[z][j];
  124.  
  125. }
  126. cout << C[i][j] << " ";
  127. }
  128. cout << endl;
  129. }
  130.  
  131.  
  132.  
  133.  
  134.  
  135. _getch();
  136.  
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement