第三章第三十二题(几何:点的位置)(Geometry: point position)

第三章第三十二题(几何:点的位置)(Geometry: point position)

  • *3.32(几何:点的位置)给定一个从点 p0(x0,y0) 到 p1(x1,y1)的有向线段,可以使用下面的条件来确定点p2(x2,y2)是在线段的左侧、右侧,或者在该线段上。
    在这里插入图片描述

    编写一个程序,提示用户输入三个点 p0、p1和p2,显示p2是在从p0到p1的线段的左侧、右侧,还是在线段上。
    下面是运行示例:

    Enter three points for p0, p1, and p2: 4.4 2 6.5 9.5 -5 4

    p2 is on the left side of the line

    Enter three points for p0, p1, and p2: 1 1 5 5 2 2

    p2 is on the same line

    Enter three points for p0, p1, and p2: 3.4 2 6.5 9.5 5 2.5

    p2 is one the right side of the line

    *3.32(Geometry: point position) Given a directed line from point p0(x0, y0) to p1(x1, y1), you can use the following condition to decide whether a point p2(x2, y2) is on the left of the line, on the right, or on the same line
    在这里插入图片描述
    Write a program that prompts the user to enter the three points for p0, p1, and p2 and displays whether p2 is on the left of the line from p0 to p1, to the right, or on the same line.

    Here are some sample runs:

    Enter three points for p0, p1, and p2: 4.4 2 6.5 9.5 -5 4

    p2 is on the left side of the line

    Enter three points for p0, p1, and p2: 1 1 5 5 2 2

    p2 is on the same line

    Enter three points for p0, p1, and p2: 3.4 2 6.5 9.5 5 2.5

    p2 is one the right side of the line

  • 参考代码:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值