|
1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #include <stdio.h>
-
- #define N 128
-
- #if 1
- #define X1 -.1
- #define X2 .4
- #define Y1 -.05
- #define Y2 .45
- #endif
-
- int tab[N][N];
-
- int main(void)
- {
- float fx, fy;
- int x, y;
-
- for(;;)
- {
- if(fscanf(stdin, "%g %g\n", &fx, &fy) != 2)
- break;
-
- x = (N - 0.000001) * (fx - X1) / (X2 - X1);
- y = (N - 0.000001) * (fy - Y1) / (Y2 - Y1);
- if(x < 0 || y < 0 || x >= N || y >= N)
- continue;
-
- tab[x][y]++;
- }
-
- for(y = 0; y < N; y++)
- {
- for(x = 0; x < N; x++)
- printf("%g %g %i\n", (float)x * (X2 - X1) / (N - 1) + X1,
- (float)y * (Y2 - Y1) / (N - 1) + Y1, tab[x][y]);
- printf("\n");
- }
-
- return 0;
- }
|