void calc(int X) { int covered = 1, dx, dy; db d; qt = 0; for (int i = 1, tmp; i <= n; ++i) if (X != i && (dx = x[i] - x[X], dy = y[i] - y[X], tmp = judge(d = sqrt(dx*dx + dy*dy), r[X], r[i])) > 0) if (tmp == 1) ++covered; else { inter(X, i, dx, dy, d, alp[qt + 1], alp[qt + 2]); q[++qt] = 1, p[qt] = qt; q[++qt] =-1, p[qt] = qt; if (eps(alp[qt - 1] - alp[qt]) > 0) { alp[++qt] = 0, q[qt] = 1, p[qt] = qt; alp[++qt] =BP, q[qt] =-1, p[qt] = qt; } } if (!qt) {ans[covered] += r[X] * r[X] * BP; return;} qsort(p + 1, qt, sizeof(p[0]), cmpor); ans[covered] += calcarea(X, 0, alp[p[1]]) + calcarea(X, alp[p[qt]], BP); for (int i = 1; i < qt; ++i) covered += q[p[i]], ans[covered] += calcarea(X, alp[p[i]], alp[p[i + 1]]); }
// // structures void structures() { t_point *pt = makepoint(2, 3, "alfa"); printpoint(pt); t_rect *rect = makerect(*makepoint(10, 10, "p1"), *makepoint(20, 20, "p2")); printrect(rect); printf("Area: %d\n", calcarea(rect)); printf("Area: %d\n", calcarea2(*rect)); free(pt); free(rect); }
int main() { double start, stop; int steps; printf("Enter the x-coordinate to start at:\n"); scanf("%lf", &start ); printf("Enter the x-coordinate to stop at:\n"); scanf("%lf", &stop ); printf("Enter number of steps \n"); scanf("%d", &steps ); calcarea(start, stop, steps); return 0; }
int main() { printf("%d \n", calcarea(5)); printf("%d \n", func(15)); return 0; }