fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const double pi = M_PI;
  5.  
  6. double P[8][8] = {
  7. {187, 188, 189, 202, 209, 175, 66, 41},
  8. {191, 186, 193, 209, 193, 98, 40, 39},
  9. {188, 187, 202, 202, 144, 53, 35, 37},
  10. {189, 195, 206, 172, 58, 47, 43, 45},
  11. {197, 204, 194, 106, 50, 48, 42, 45},
  12. {208, 204, 151, 50, 41, 41, 41, 53},
  13. {209, 179, 68, 42, 35, 36, 40, 47},
  14. {200, 117, 53, 41, 34, 38, 39, 63}
  15. };
  16.  
  17. int main(int argc, char *argv[]) {
  18. double T[8][8];
  19. for (int u = 0; u < 8; u++) {
  20. for (int v = 0; v < 8; v++) {
  21. double cU, cV;
  22. cU = sqrt((u == 0 ? 1 : 2) / 8.0);
  23. cV = sqrt((v == 0 ? 1 : 2) / 8.0);
  24. for (int x = 0; x < 8; x++) {
  25. for (int y = 0; y < 8; y++) {
  26. T[u][v] += P[x][y] * cU * cV * cos((2 * x + 1) * u * pi / 16.0) * cos((2 * y + 1) * v * pi / 16.0);
  27. }
  28. }
  29. }
  30. }
  31.  
  32. for (int i = 0; i < 8; i++) {
  33. for (int j = 0; j < 8; j++) {
  34. printf("%10.3f", T[i][j]);
  35. }
  36. printf("\n");
  37. }
  38. }
  39.  
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
   915.625   451.303    25.608   -12.553    16.125   -12.342     7.929    -7.308
   216.791    19.778  -228.152   -25.698    23.049    -0.086     6.372     1.956
    -2.001   -77.388   -23.757   102.898    45.248   -23.651    -4.447    -5.079
    30.089     2.376    19.529    28.564   -51.132   -32.501    12.280     4.496
     5.125   -22.097    -2.154    -1.902   -17.375    20.849    23.217246999747525534840917715477447147730434727162720319903738037889138688.000
    -0.404    -0.804     7.518     6.237    -9.646     5.696    -9.534   -19.857
     5.294    -5.261    -2.447    -2.409    -3.453    -2.093    10.007    10.986
     0.863     0.695    -7.743     9.319     2.661    -5.390    -6.723     2.461