| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 372 人关注过本帖
标题:[求助]比较大小时只比最后一位的,怎么办
只看楼主 加入收藏
Qoo里的鱼
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-5-9
收藏
 问题点数:0 回复次数:0 
[求助]比较大小时只比最后一位的,怎么办

Private x(), y(), m, n, p(5), q(5), r(5), s(5), u(5), v(5), a, b, c, Pmax, Pmin, Pn As Long


Private Sub text1_change() '输入行数
m = Text1.Text
End Sub
Private Sub text2_change() '输入列数

n = Text2.Text
End Sub
Private Sub command1_click() '输入数据
ReDim x(m, n)
List1.Clear
For i = 1 To m
For j = 1 To n
x(i, j) = InputBox("x(" + CStr(i) + "," + CStr(j) + ")=", "输入读数")
List1.AddItem "x(" + CStr(i) + "," + CStr(j) + ")=" + CStr(x(i, j))
Next j
Next i
End Sub
'找高点,第二高点,低点
Private Sub command2_click()
Pmax = 0
a = 0
For i = 1 To m
For j = 1 To n
If x(i, j) > Pmax Then
Pmax = x(i, j)
p(0) = i
q(0) = j
a = 1
ElseIf x(i, j) = Pmax Then
p(a) = i
q(a) = j
a = a + 1
End If
Next j
Next i
Print Pmax, p(0), q(0), p(1), q(1), p(2), q(2), a '找两个或多个高点
Pn = 0
For i = 1 To m
For j = 1 To n
If x(i, j) <> Pmax Then
If x(i, j) > Pn Then
Pn = x(i, j)
r(0) = i
s(0) = j
b = 1
ElseIf x(i, j) = Pn Then
r(b) = i
s(b) = j
b = b + 1
End If
End If
Next j
Next i
'Print Pn, r(0), s(0), r(1), s(1), r(2), s(2), b '找俩个或多个第二高点
Pmin = x(1, 1)
c = 0
For i = 1 To m
For j = 1 To n
If x(i, j) < Pmin Then
Pmin = x(i, j)
u(0) = i
v(0) = j
c = 1
ElseIf x(i, j) = Pmin Then
u(c) = i
v(c) = j
c = c + 1
End If
Next j
Next i
'Print Pmin, u(0), v(0), u(1), v(1), u(2), v(2), c找两个或多个最小点
'k = (p(0) - u(0)) / (q(0) - v(0))
't = (-1) / k '方程:0=tj-i+p(0)-tq(0)
'd = (t * s(0) - r(0) + p(0) - t * q(0)) / Sqr(t ^ 2 + 1 + (p(0) - t * q(0)) ^ 2)
'Print k, t, d '斜率,轴斜率,第二点到第一点距离
End Sub

2006-05-17 13:20
快速回复:[求助]比较大小时只比最后一位的,怎么办
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021522 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved