首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >1007: 矩形着色

1007: 矩形着色

作者头像
渔父歌
发布2019-04-25 10:53:32
发布2019-04-25 10:53:32
1.1K0
举报
文章被收录于专栏:数据结构笔记数据结构笔记

原题地址

代码语言:javascript
复制
#include<iostream>
#include<string>

using namespace std;

int main() {
    int n;
    cin >> n;
    
    string* results = new string[n];

    for (int i = 0; i < n; i++) {
        int x, y, lx, ly, rx, ry;
        cin >> x >> y;
        cin >> lx >> ly >> rx >> ry;

        //不在矩形内的情况
        if (x < lx || x > rx || y < ly || y > ry) {
            results[i] = "Outside";
        }
        //在矩形边上的情况
        else if ((x >= lx && x <= rx && (y == ly || y == ry)) || (y >= ly && y <= ry && (x == lx || x == rx))) {
            results[i] = "On";
        }
        //在矩形内部的情况
        else {
            results[i] = "Inside";
        }
    }

    for (int i = 0; i < n; i++) {
        cout << results[i] << endl;
    }

    return 0;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019.04.17 ,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档