fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. srand(time(NULL));
  11. int width = 8;
  12. int height = 8;
  13. int blok[8][8];
  14. int suma = 0;
  15. for(int y = 0; y < height; y++) {
  16. for(int x = 0; x < width; x++) {
  17. int a;
  18. cin >> a;
  19. blok[x][y] = a;
  20. }
  21. }
  22. int transformatakosinusowa[8][8];
  23. for(int k = 0; k < height/8; k++) {
  24. for(int l = 0; l < width/8; l++) {
  25. float c_u, c_v;
  26. for(int u = 0; u < 8; u++) {
  27. for(int v = 0; v < 8; v++) {
  28. if(u == 0) c_u = 1/sqrt(2); else c_u = 1;
  29. if(v == 0) c_v = 1/sqrt(2); else c_v = 1;
  30. suma = 0;
  31. for(int x = 0; x < 8; x++) {
  32. for(int y = 0; y < 8; y++) {
  33. suma += blok[x][y] * cos(((2*x+1)/16)*u*M_PI) * cos(((2*y+1)/16)*v*M_PI);
  34. }
  35. }
  36. transformatakosinusowa[u][v] = c_u*c_v*suma/4;
  37. cout << u << " " << v << " " << blok[u][v] << " " << transformatakosinusowa[u][v] << "\n";
  38. }
  39. }
  40. }
  41. }
  42. }
  43.  
Success #stdin #stdout 0.01s 2684KB
stdin
186 198 199 190 182 177 182 197
179 184 183 176 173 172 175 184
188 182 180 178 174 172 171 166
132 130 139 146 151 169 191 201
131 134 137 140 139 139 139 138
153 157 161 172 177 145 89 49
190 178 192 196 120 43 39 47
176 184 187 112 41 39 43 44
stdout
0 0 186 1204
0 1 179 1703
0 2 188 1703
0 3 132 1703
0 4 131 1703
0 5 153 1703
0 6 190 1703
0 7 176 1703
1 0 198 1703
1 1 184 2409
1 2 182 2409
1 3 130 2409
1 4 134 2409
1 5 157 2409
1 6 178 2409
1 7 184 2409
2 0 199 1703
2 1 183 2409
2 2 180 2409
2 3 139 2409
2 4 137 2409
2 5 161 2409
2 6 192 2409
2 7 187 2409
3 0 190 1703
3 1 176 2409
3 2 178 2409
3 3 146 2409
3 4 140 2409
3 5 172 2409
3 6 196 2409
3 7 112 2409
4 0 182 1703
4 1 173 2409
4 2 174 2409
4 3 151 2409
4 4 139 2409
4 5 177 2409
4 6 120 2409
4 7 41 2409
5 0 177 1703
5 1 172 2409
5 2 172 2409
5 3 169 2409
5 4 139 2409
5 5 145 2409
5 6 43 2409
5 7 39 2409
6 0 182 1703
6 1 175 2409
6 2 171 2409
6 3 191 2409
6 4 139 2409
6 5 89 2409
6 6 39 2409
6 7 43 2409
7 0 197 1703
7 1 184 2409
7 2 166 2409
7 3 201 2409
7 4 138 2409
7 5 49 2409
7 6 47 2409
7 7 44 2409