Language: C++

#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#define INF 1000000000
using namespace std;
const double g = 9.8;
int n, m, x, y;
int x1[105], y1[105], x2[105], z2[105];
double width(int* x, int* y, int n, double xx) {
    double lb = INF, ub = -INF;
    for (int i = 0; i < n; ++i) {
        double x1 = x[i], y1 = y[i], x2 = x[(i + 1) % n], y2 = y[(i + 1) % n];
        if ((x1 - xx) * (x2 - xx) <= 0 && x1 != x2) {
            double y = y1 + (y2 - y1) * (xx - x1) / (x2 - x1);
            lb = min(lb, y);
            ub = max(ub, y);
        }
    }//printf("%f\n",ub-lb);
    return max(0.0, ub - lb);
}
int main() {
    while(scanf("%d %d", &m, &n) && m && n) {
        vector<int> xs;
        int min1 = INF, max1 = -INF, min2 = INF, max2 = -INF;
        for (int i = 0; i < m; ++i) {
            scanf("%d %d", x1 + i, y1 + i);
            min1 = min(min1, x1[i]);
            max1 = max(max1, x1[i]);
            xs.push_back(x1[i]);
        }
        for (int i = 0; i < n; ++i) {
            scanf("%d %d", x2 + i, z2 + i);
            min2 = min(min2, x2[i]);
            max2 = max(max2, x2[i]);
            xs.push_back(x2[i]);
        }
        sort(xs.begin(), xs.end());
        double ans = 0;
        for (int i = 0; i + 1 < xs.size(); ++i) {
            double a = xs[i], b = xs[i + 1];
            double c = (a + b) / 2;
            if (min1 <= c && c <= max1 && min2 <= c && c <= max2) {
                double fa = width(x1, y1, m, a) * width(x2, z2, n, a);
                double fb = width(x1, y1, m, b) * width(x2, z2, n, b);
                double fc = width(x1, y1, m, c) * width(x2, z2, n, c);
                ans += (b - a) / 6 * (fa + 4 * fc + fb);
            }
        }
        printf("%.10f\n", ans);
    }
    return 0;
}



Compiler output:
a.cc:9:20: error: 'int y1 [105]' redeclared as different kind of entity
    9 | int x1[105], y1[105], x2[105], z2[105];
      |                    ^
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/cstdio:41,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
  257 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:27:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   27 |             scanf("%d %d", x1 + i, y1 + i);
      |                                    ~~~^~~
a.cc:44:34: error: cannot convert 'double (*)(double) noexcept' to 'int*'
   44 |                 double fa = width(x1, y1, m, a) * width(x2, z2, n, a);
      |                             ~~~~~^~~~~~~~~~~~~~
      |                                  |
      |                                  double (*)(double) noexcept
a.cc:10:27: note:   initializing argument 2 of 'double width(int*, int*, int, double)'
   10 | double width(int* x, int* y, int n, double xx) {
      |                      ~~~~~^
a.cc:45:34: error: cannot convert 'double (*)(double) noexcept' to 'int*'
   45 |                 double fb = width(x1, y1, m, b) * width(x2, z2, n, b);
      |                             ~~~~~^~~~~~~~~~~~~~
      |                                  |
      |                                  double (*)(double) noexcept
a.cc:10:27: note:   initializing argument 2 of 'double width(int*, int*, int, double)'
   10 | double width(int* x, int* y, int n, double xx) {
      |                      ~~~~~^
a.cc:46:34: error: cannot convert 'double (*)(double) noexcept' to 'int*'
   46 |                 double fc = width(x1, y1, m, c) * width(x2, z2, n, c);
      |                             ~~~~~^~~~~~~~~~~~~~
      |                                  |
      |                                  double (*)(double) noexcept
a.cc:10:27: note:   initializing argument 2 of 'double width(int*, int*, int, double)'
   10 | double width(int* x, int* y, int n, double xx) {
      |                      ~~~~~^