25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

42 lines
721 B

  1. #include <stdio.h>
  2. #define N 128
  3. #if 1
  4. #define X1 -.1
  5. #define X2 .4
  6. #define Y1 -.05
  7. #define Y2 .45
  8. #endif
  9. int tab[N][N];
  10. int main(void)
  11. {
  12. float fx, fy;
  13. int x, y;
  14. for(;;)
  15. {
  16. if(fscanf(stdin, "%g %g\n", &fx, &fy) != 2)
  17. break;
  18. x = (N - 0.000001) * (fx - X1) / (X2 - X1);
  19. y = (N - 0.000001) * (fy - Y1) / (Y2 - Y1);
  20. if(x < 0 || y < 0 || x >= N || y >= N)
  21. continue;
  22. tab[x][y]++;
  23. }
  24. for(y = 0; y < N; y++)
  25. {
  26. for(x = 0; x < N; x++)
  27. printf("%g %g %i\n", (float)x * (X2 - X1) / (N - 1) + X1,
  28. (float)y * (Y2 - Y1) / (N - 1) + Y1, tab[x][y]);
  29. printf("\n");
  30. }
  31. return 0;
  32. }