zoukankan      html  css  js  c++  java
  • rwkj 1356 点与矩形


    C++:类与对象4(对象成员:点与矩形)
    时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte
    总提交:467 测试通过:290

    描述


    定义点类,再定义矩形类,矩形包含2个点,分别表示对角顶点。输入2个顶点的坐标,计算矩形的面积。


    输入


    输入包含n组测试例, 第1行是测试组数。

    第2行--第n+1行为测试数据,每组测数据有4个整数,表示 2个顶点的坐标。


    输出

    每个矩形的面积。

    样例输入

    2
    0 0 4 5
    0 7 8 0

    样例输出

    20
    56


    //1356
    #include <iostream>
    #include <cmath>
    using namespace std;
    int main()
    { int n;
    int x1,y1,x2,y2;
    cin>>n;
    while (n--)
    { cin>>x1>>y1>>x2>>y2;
    cout<<abs(x1-x2)*abs(y1-y2)<<endl;
    }
    return 0;
    }

    #include <iostream>
    #include<cmath>
    using namespace std;
    class square
    {
    int a,b,c,d,s;
    public:
    void voluation(int x1,int y1,int x2,int y2)
    {
    a=x1;b=y1;c=x2;d=y2;
    }
    void count()
    {
    s=abs((c-a)*(d-b));
    }
    void Put()
    {
    cout<<s<<endl;
    }
    };
    int main()
    {
    int n,x1,x2,y1,y2;
    square x;
    cin>>n;
    while(n--)
    {
    cin>>x1>>y1>>x2>>y2;
    x.voluation(x1,y1,x2,y2);
    x.count();
    x.Put();
    }
    return 0;
    }

  • 相关阅读:
    行转列
    multipath 安装配置
    网卡绑定
    numa对MySQL多实例性能影响
    Fatal NI connect error 12170
    REVOKE DBA权限要小心
    Oracle 数据库整理表碎片
    listagg 函数
    10046 事件补充
    tkprof 解释
  • 原文地址:https://www.cnblogs.com/2014acm/p/3911218.html
Copyright © 2011-2022 走看看