有人可以解释一下输出吗? [英] Can any one explain me the output please?

查看:68
本文介绍了有人可以解释一下输出吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定左下角(x,y)的坐标,2个矩形的长度(l)和宽度(w),编写程序以找到两个给定矩形的交点。



假设:交叉总是发生。



测试用例



输入1



3 8 1515



2 6 10 10



输出1



2 6 17 16



我是什么尝试过:



Given the coordinates of the lower left corner (x,y), the length (l) and width(w) of 2 rectangles, Write a program to find the intersection of the two given rectangles.

Assume: Intersection always happens.

Test Case

Input 1

3 8 1515

2 6 10 10

Output 1

2 6 17 16

What I have tried:

#include <stdio.h>
#define max(x, y) (((x) > (y)) ? (x) : (y))
#define min(x, y) (((x) < (y)) ? (x) : (y))
int main()
{

int x1,y1,x3,y3,l1,l2,w1,w2;
scanf("%d %d %d %d %d %d %d %d",&x1,&y1,&l1,&w1,&x3,&y3,&l2,&w2);




int x2,y2,x4,y4;
x2=x1+l1;
y2=y1+w1;
x4=x3+l2;
y4=y3+w2;


int x5 = max(x1, x3);
int y5 = max(y1, y3);
int x6 = min(x2, x4);
int y6 = min(y2, y4);

printf("%d,%d,%d,%d",x5,y5,x1,y6);


return 0;
}

推荐答案

要解释的是什么?

你写了它,你知道它做了什么。

在最终的 printf 中应该是x6而不是x1,但是......



(哦,你的输出1数字是错的:它是2,6,12,16而不是2,6,17,16)
What's to explain?
You wrote it, you know what it does.
It should probably be x6 rather than x1 in the final printf, but ...

(Oh, and your "Output 1" numbers are wrong: it's "2, 6, 12, 16" not "2, 6, 17, 16")


这篇关于有人可以解释一下输出吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆