当前位置:   article > 正文

C语言之IoU_cpp iou x y w h

cpp iou x y w h

欢迎进入我的C语言世界

题目

Problem Description

Xzz need to calculate Intersection over Union(IoU) of two rectangles, can you help him?

rectangle (x, y, w, h) means a rectangle MNPQ, M(x,y), N(x, y+h), P(x+w, y+h), Q(x+w, y).

IoU = Area of overlap / Area of union.

Input

First line of the input file contains an integer T(0 < T <= 100) that indicates how many cases of inputs are there.

The description of each case is given below:

The first line of each input set contains integer x1, y1, w1, h1.

The second line of each input set contains integer x2, y2, w2, h2.

0 ≤ x, y, w, h ≤ 100000

Output
The description of output for each test case is given below:

The first line of the output for each test case contains number k- the IoU of two rectangles.

Output should be rounded to 2 digits after decimal point.

Sample Input

2
1 1 1 1
1 1 2 2
1 1 2 1
1 1 1 2

Sample Output

0.25
0.33

答案

下面展示 实现代码

#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int main()
{
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/114139
推荐阅读
相关标签
  

闽ICP备14008679号