Polnochniy

Untitled

Jan 22nd, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. using namespace std;
  4. const int N = 3;
  5. const int P = 3;
  6.  
  7. int main()
  8. {
  9. int a[N][P];
  10. int b[N][P];
  11. int c[N][P];
  12. setlocale(LC_ALL, "Rus");
  13. srand(time(NULL));
  14. cout << " Найтие умножение 2 матриц " << endl;
  15. cout << "Вывод элементов" << endl;
  16. cout << "Для матрицы А" << endl;
  17. for (int i = 0; i < N; i++)
  18. {
  19. for (int j = 0; j < P; j++)
  20. {
  21. a[i][j] = rand() % 12;
  22. cout << a[i][j] << " ";
  23. }
  24. cout << endl;
  25. }
  26. cout << "Для матрицы B" << endl;
  27. for (int i = 0; i < N; i++)
  28. {
  29. for (int j = 0; j < P; j++)
  30. {
  31. b[i][j] = rand() % 12;
  32. cout << b[i][j] << " ";
  33. }
  34. cout << endl;
  35. }
  36. cout << "Умножение матриц равно = " << endl;
  37. for (int i = 0; i < N; i++)
  38. {
  39. for (int j = 0; j < P; j++)
  40. {
  41. c[i][j] = 0;
  42. for (int k = 0; k < N ; k++)
  43. {
  44. c[i][j] += a[i][k] * b[k][j];
  45. }
  46. cout << c[i][j] << " ";
  47. }
  48. cout << endl;
  49. }
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment