http://oj.acm.zstu.edu.cn/JudgeOnline/problem.php?cid=4034&pid=10

C++版本一

#include <iostream>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
 
using namespace std;
 
const int N=1000;
 
int x,x2,y,y2;
int map[N][N];
int main()
{   
    while(scanf("%d%d%d%d",&x,&y,&x2,&y2)!=EOF){
        memset(map,0,sizeof(map));
        x+=100;
        y+=100; 
        x2+=100;
        y2+=100; 
    for(int i=min(x,x2);i<max(x,x2);i++){
        for(int j=min(y,y2);j<max(y,y2);j++){
        map[i][j]++;
    }
    }
     
            scanf("%d%d%d%d",&x,&y,&x2,&y2);
                x+=100;
        y+=100; 
        x2+=100;
        y2+=100; 
             for(int i=min(x,x2);i<max(x,x2);i++){
        for(int j=min(y,y2);j<max(y,y2);j++){
        map[i][j]++;
    }
    }
    int ans=0;
     for(int i=0;i<200+10;i++){
        for(int j=0;j<200+10;j++){
    if(map[i][j]==2)
    ans++;
    }
    }
        printf("%d\n",ans);
 
    }
    //cout << "Hello world!" << endl;
    return 0;
}

C++版本二

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;
 
int main(){
    int x1,x2,x3,x4,y1,y2,y3,y4,x,y,xmin,ymin,xmax,ymax;
    while(~scanf("%d%d%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)){
        if(x2<=x3||y2>=y3||x1>=x4||y1<=y4){
            printf("0\n");
            continue;
        }
        if(x1>x3)xmin=x1;
        else xmin=x3;
        if(x2>x4)xmax=x4;
        else xmax=x2;
        x=xmax-xmin;
 
        if(y1>y3)ymax=y3;
        else ymax=y1;
        if(y2>y4)ymin=y2;
        else ymin=y4;
        y=ymax-ymin;
        x=x*y;
        if(x<0)x=0;
        printf("%d\n",x);
    }
    return 0;
}