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
;
}
查看全文
相关阅读:
rtmp_specification_1.0
RTSP Spectification
FFMPEG 入门
Spring Cloud Gateway + Spring Oauth 2.0 整合(服务端与资源端分离)
深入浅出 Spring Cache 使用与整合(附源码解析)
Java集合之ArrayList源码分析
SpringBoot+Mybatis+MybatisPlus 入门整合(三)
SpringBoot+Mybatis+Generator 逆向工程使用(二)
SpringBoot+Mybatis整合入门(一)
SpringBoot+SpringData 整合入门
原文地址:https://www.cnblogs.com/SQL/p/933467.html
最新文章
Git忽略特殊文件
Git创建和删除标签
Git远程推送和抓取分支
Git储藏工作现场
Git解决冲突
Git创建合并和删除分支
Git添加和克隆远程库
Git版本回退和撤销修改
Git修改和提交文件
Git删除和恢复文件
热门文章
Git创建版本库和添加文件
Git安装
python+Selenium之操作滚动条
【NPDP笔记】第七章 产品生命周期管理
【NPDP笔记】第五章 工具与度量
【NPDP笔记】第六章 市场研究
【NPDP笔记】第三章 新产品流程
【NPDP笔记】第四章 文化组织与团队
【NPDP笔记】第二章 组合管理
【NPDP笔记】第一章 新产品开发战略
Copyright © 2011-2022 走看看