4 条题解

  • 3
    @ 2023-7-28 16:24:22

    #include #include #include #include using namespace std; int x,y,b,c,d,m,n,s; struct chuang { int l,r,f,t; }a[99]; int main() { int lmax,rmax,fmax,tmax; scanf("%d%d%d%d",&a[1].l,&a[1].r,&a[1].f,&a[1].t); scanf("%d%d%d%d",&a[2].l,&a[2].r,&a[2].f,&a[2].t); lmax=a[1].l>a[2].l?a[1].l:a[2].l; rmax=a[1].ra[2].r?a[1].r:a[2].r; fmax=a[1].fa[2].f?a[1].f:a[2].f; tmax=a[1].t<a[2].t?a[1].t:a[2].t; if(lmax<rmax&&fmax<tmax) { printf("%d",(rmax-lmax)*(tmax-fmax)); } else printf("0"); return 0; }

    • @ 2023-7-28 20:41:38

      OK呀,懂了,看的时候帮忙调整了一下格式😄

      #include<cstdio> 
      #include<cstring> 
      #include<cmath> 
      #include<algorithm> 
      using namespace std; 
      int x,y,b,c,d,m,n,s; 
      struct chuang 
      { 
          int l,r,f,t; 
      }a[99]; 
      int main() 
      { 
          int lmax,rmax,fmax,tmax; 
          scanf("%d%d%d%d",&a[1].l,&a[1].r,&a[1].f,&a[1].t); 
          scanf("%d%d%d%d",&a[2].l,&a[2].r,&a[2].f,&a[2].t); 
          lmax=a[1].l>a[2].l?a[1].l:a[2].l; 
          rmax=a[1].ra[2].r?a[1].r:a[2].r; 
          fmax=a[1].fa[2].f?a[1].f:a[2].f; 
          tmax=a[1].t<a[2].t?a[1].t:a[2].t; 
          if(lmax<rmax&&fmax<tmax) 
          { 
              printf("%d",(rmax-lmax)*(tmax-fmax)); 
          } 
          else printf("0"); 
          return 0; 
      }
      
    • @ 2023-8-11 19:10:49

      亦或是不用结构体 (因为不会)

      #include<cstdio>
      using namespace std;
      
      int map[1000][1000];
      
      int main(){
          int x1, y1, x2, y2, xx1, yy1, xx2, yy2;
          scanf("%d%d%d%d", &x1, &x2, &y1, &y2);
          scanf("%d%d%d%d", &xx1, &xx2, &yy1, &yy2);
          
          for(int i=x1; i<x2; i++){
              for(int j=y1; j<y2; j++){
                  map[i][j] = 1;
              }
          }
      
          int c=0;
          for(int i=xx1; i<xx2; i++){
              for(int j=yy1; j<yy2; j++){
                  if(map[i][j]) c++;
              }
          }
      
          printf("%d\n", c);
      
          return 0;
      }
      
    • @ 2023-8-19 10:55:57

      @这样会爆内存(考试亲身经历)

    • @ 2023-9-30 15:12:53

      @ 也许会吧awa,速速补习 struct!!!

  • 1
    @ 2023-11-25 19:45:25
    #include<algorithm>
    using namespace std;
    int z1,y1,s1,x1; 
    struct c
    {
    	int z,y,s,x;
    }a[99];
    int main()
    {
    	cin>>a[1].z>>a[1].y>>a[1].s>>a[1].x;
    	cin>>a[2].z>>a[2].y>>a[2].s>>a[2].x;
    	if(a[1].z>a[2].z) z1=a[1].z;
    	else z1=a[2].z;
    	if(a[1].y<a[2].y) y1=a[1].y;
    	else y1=a[2].y;
    	if(a[1].s>a[2].s) s1=a[1].s;
    	else s1=a[2].s;
    	if(a[1].x<a[2].x) x1=a[1].x;
    	else x1=a[2].x;
    	if(z1<y1&&s1<x1)
    	cout<<(y1-z1)*(x1-s1);
    	else cout<<0;
    	return 0;
     }
    
    • 0
      @ 2023-11-25 18:19:47
      using namespace std;
      struct twindow{
          int left,right,top,bottom;
      };
      twindow wina,winb,tmp;
      
      twindow indata(){
          twindow tmp;
          cin >> tmp.left >> tmp.right >> tmp.top >> tmp.bottom;
          return tmp;
      }
      
      int main(){
      
          wina = indata();
          winb = indata();
          tmp.left = max(wina.left,winb.left);
          tmp.right = min(wina.right,winb.right);
          tmp.top = max(wina.top,winb.top);
          tmp.bottom = min(wina.bottom,winb.bottom);
          int s = (tmp.right - tmp.left) * (tmp.bottom - tmp.top);
          if((tmp.right <= tmp.left) || (tmp.bottom <= tmp.top)) s = 0;
          cout << s << endl;
      	return 0;
      }
      
      • -4
        @ 2023-11-25 19:07:38

        #include #include using namespace std; struct zuobiao {int zuo,you,shang,xia; }a[3]; int jisuan(int a1,int a2,int a3,int a4,int b1,int b2,int b3,int b4) { int heng,zong; heng=(a2-a1+b2-b1-abs(a1-b1)-abs(a2-b2))/2; zong=(a4-a3+b4-b3-abs(a3-b3)-abs(a4-b4))/2; return heng*zong; } int main() { int i; for(i=1;i<=2;i++) { cin>>a[i].zuo>>a[i].you>>a[i].shang>>a[i].xia; } if(((a[1].zuo<=a[2].you)&&(a[1].you>=a[2].zuo))&&((a[1].xia>=a[2].shang)&&(a[1].shang<=a[2].xia))) cout<<jisuan(a[1].zuo,a[1].you,a[1].shang,a[1].xia,a[2].zuo,a[2].you,a[2].shang,a[2].xia); else cout<<0; } 数学方法 相交=(1长+2长-左(上)差-右(下)差)/2

      • 1

      信息

      ID
      387
      时间
      1000ms
      内存
      256MiB
      难度
      5
      标签
      递交数
      126
      已通过
      44
      上传者