fork(8) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin>>n;
  7. double x[n][n],y[n][n],z[n][n],mu=0;
  8. for (int i = 0; i < n; i++){
  9. for (int j = 0; j < n; j++){
  10. cin>>x[i][j];
  11. y[j][i]=x[i][j];
  12. }
  13. }
  14. for (int i = 0; i < n; i++){
  15. for (int j = 0; j < n; j++){
  16. for (int p = 0; p < n; p++){
  17. mu += x[i][p]*y[p][j];
  18. }
  19. z[i][j] = mu;
  20. mu = 0;
  21. }
  22. }
  23. for (int i = 0; i < n; i++){
  24. for (int j = 0; j < n; j++){
  25. cout<<z[i][j]<<" ";
  26. }
  27. cout<<endl;
  28. }
  29. }
  30.  
  31.  
Success #stdin #stdout 0s 3464KB
stdin
4
1 2 3 4
5 6 7 8
9 0 1 2
3 4 5 6
stdout
30 70 20 50 
70 174 68 122 
20 68 86 44 
50 122 44 86