高二数学必修3 疑难

来源:百度知道 编辑:UC知道 时间:2024/05/24 10:29:36
老师没讲过这种体型 ``` 问: 写出求过P1(3,2),P2(—1,6)两点的直线的斜率的一个算法? 希望数学高手帮忙解答一下 谢谢

clear
input "P1点横坐标" to x1
input "P1点纵坐标" to y1
input "P2点横坐标" to x2
input "P1点纵坐标" to y2
if x1=x2 and y1<>y2
then
print k不存在
else
if y1=y2 and x1<>x2
then
print k=0
else
k=abs((y1-y2)/(x1-x2))
print k
endif
endif
在VF中,运行中成功。

既然知道2个点了就直接k=(y1-y2)/(x1-x2)=(6-2)/(-1-3)=-1

知道两个点(X,Y)(x,y)。斜率K=(Y-y)/(X-x)

k=(y1-y2)/(x1-x2)=(6-2)/(-1-3)=-1