fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int n;
  7. cin >> n;
  8. double A[n][n];
  9. for(int i = 0; i < n; i++){
  10. for(int j = 0; j < n; j++){
  11. cin >> A[i][j];
  12. }
  13. }
  14.  
  15. double B[n][n];
  16. for(int i = 0; i < n; i++){
  17. for(int j = 0; j < n; j++){
  18. B[i][j] = 0;
  19. if (i < j){B[i][j] = 10 * 0.1 / ((i+1) + (j+1) -1);}
  20. else {
  21. if (i == j){B[i][j] = 0;}
  22. else {B[i][j] = -10 * 0.1 / ((i+1) + (j+1) -1);}
  23. }
  24. }
  25. }
  26.  
  27. double C[n][n];
  28. for(int i = 0; i < n; i++){
  29. for(int j = 0; j < n; j++){
  30. C[i][j] = 0;
  31. for(int k = 0; k < n; k++){
  32. C[i][j] += A[i][k] * B[k][j];
  33. }
  34. }
  35. }
  36.  
  37. for(int i = 0; i < n; i++){
  38. for(int j = 0; j < n; j++){
  39. cout << C[i][j] << " ";
  40. }
  41. cout << endl;
  42. }
  43.  
  44. return 0;
  45. }
Success #stdin #stdout 0s 3416KB
stdin
3
1 1 1 
1 1 1
1 1 1
stdout
Standard output is empty