zoukankan
html css js c++ java
PKU2074
#include
<
stdio.h
>
#include
<
string
.h
>
struct
line
{
double
x1, x2, y;
bool
ex;
}
;
line l1, l;
int
n;
double
len;
int
lineCnt;
line l2[
30
];
void
CNT()
{
int
i;
for
(i
=
0
; i
<
lineCnt; i
++
)
{
if
(l2[i].ex
&&
len
<
l2[i].x2
-
l2[i].x1)
len
=
l2[i].x2
-
l2[i].x1;
}
}
void
cut(line l1,
int
i)
{
if
(l1.x1
<=
l2[i].x1)
{
if
(l1.x2
<
l2[i].x2
&&
l1.x2
>
l2[i].x1)
l2[i].x1
=
l1.x2;
if
(l1.x2
>=
l2[i].x2)
l2[i].ex
=
0
;
}
else
if
(l1.x2
>=
l2[i].x2)
{
if
(l1.x1
<=
l2[i].x2)
l2[i].x2
=
l1.x1;
}
else
{
l2[lineCnt].x1
=
l1.x2, l2[lineCnt].x2
=
l2[i].x2, l2[lineCnt].ex
=
1
;
l2[i].x2
=
l1.x1;
lineCnt
++
;
}
}
void
func()
{
int
i;
line shadow;
double
r
=
(l1.y
-
l.y)
/
(l1.y
-
l2[
0
].y);
shadow.x1
=
l1.x2
-
(l1.x2
-
l.x1)
/
r;
shadow.x2
=
l1.x1
+
(l.x2
-
l1.x1)
/
r;
shadow.y
=
l2[
0
].y;
for
(i
=
0
; i
<
lineCnt; i
++
)
{
if
(l2[i].ex)
cut(shadow, i);
}
}
int
main()
{
while
(scanf(
"
%lf%lf%lf
"
,
&
l1.x1,
&
l1.x2,
&
l1.y)
==
3
)
{
if
(l1.x1
==
0
&&
l1.x2
==
0
&&
l1.y
==
0
)
break
;
len
=
0
;
scanf(
"
%lf%lf%lf
"
,
&
l2[
0
].x1,
&
l2[
0
].x2,
&
l2[
0
].y);
l2[
0
].ex
=
1
;
lineCnt
=
1
;
scanf(
"
%d
"
,
&
n);
int
i;
for
(i
=
0
; i
<
n; i
++
)
{
scanf(
"
%lf%lf%lf
"
,
&
l.x1,
&
l.x2,
&
l.y);
if
(l.y
<
l1.y
&&
l.y
>=
l2[
0
].y)
func();
}
CNT();
if
(len
>
0
)
printf(
"
%.2f\n
"
, len);
else
printf(
"
No View\n
"
);
}
return
0
;
}
查看全文
相关阅读:
Mybatis与Hibernate概述
Linux命令中:rsync和scp之间的区别
更改了ssh文件下,还没有权限
karaf 控制台 常用linux指令(2)
karaf 控制台 常用linux指令(1)
POM文件详解(2)
POM文件详解(1)
maven配置parent pom查找策略
排序算法性能比较
Eclipse下用NDK编译生成so文件
原文地址:https://www.cnblogs.com/SQL/p/933467.html
最新文章
Unity2018 Build AssetBundle过程中崩溃的解决办法
Unity2018 Package Manager消失的解决办法
【转】Android studio安装与配置
[转]C# 使用Conditional特性而不是#if条件编译
Unity-NGUI UILabel换行
Unity-修改Debug日志文本颜色
[转].Net-C#的委托(代理)和事件
[转]Unity-移动设备可用的压缩解压缩源码
Unity-批量修改Prefab上的属性
iOS-ERROR ITMS-90086:"missing 64-bit support...解决办法
热门文章
Leetcode刷题记录[java]——717 1-bit and 2-bit Characters
Leetcode刷题记录[java]——695 Max Area of Island
Leetcode刷题记录[java]——485 Max Consecutive Ones
Leetcode刷题记录[java]——566 Reshape the Matrix
Leetcode刷题记录[java]——561 Array Partition I
Leetcode刷题记录[python]——283 Move Zeroes
Leetcode刷题记录[python]——104 Maximum Depth of Binary Tree
Leetcode刷题记录[python]——258 Add Digits
Leetcode刷题记录[python]——349 Intersection of Two Arrays
Leetcode刷题记录[python]——344 Reverse String
Copyright © 2011-2022 走看看