zoukankan      html  css  js  c++  java
  • 结构体-重叠窗口面积

    输入两个窗口位置(左边横坐标,右边横坐标,上边纵坐标,下边纵坐标),输出重叠部分面积

    代码:

     1 #include <iostream>
     2 #include <string>
     3 #include <algorithm>
     4 using namespace std;
     5 struct ck
     6 {
     7     int x1,y1,x2,y2;
     8 };
     9 int main()
    10 {
    11     ck ck1,ck2,t;
    12     cin>>ck1.x1>>ck1.x2>>ck1.y1>>ck1.y2;
    13     cin>>ck2.x1>>ck2.x2>>ck2.y1>>ck2.y2;
    14     t.x1=max(ck1.x1,ck2.x1);
    15     t.y1=max(ck1.y1,ck2.y1);
    16     t.x2=min(ck1.x2,ck2.x2);
    17     t.y2=min(ck1.y2,ck2.y2);
    18     if(t.x2>t.x1&&t.y2>t.y1)
    19     {
    20         cout<<(t.x2-t.x1)*(t.y2-t.y1);
    21     }
    22     else
    23     {
    24         cout<<"bcd";
    25     }
    26 }

    运行结果:

  • 相关阅读:
    14.3
    14.2
    14.1
    第14章 抽象类和接口
    13.5
    JAVA异常处理
    12.9
    12.7
    vs 常用快捷键
    click()和onclick()的区别
  • 原文地址:https://www.cnblogs.com/wanjinliu/p/11397241.html
Copyright © 2011-2022 走看看