| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1173 人关注过本帖
标题:VB的数据溢出,找不到在哪!
取消只看楼主 加入收藏
solitude1984
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-4-23
收藏
 问题点数:0 回复次数:0 
VB的数据溢出,找不到在哪!

前面的下界问题解决了,但是现在又出现数据溢出,我检查了,定义没有问题!但是就是没法通过!导师这两天要看!急死了,先谢谢大家了!
Private Sub Command1_Click()
Dim a, b, ni, c, ok As Integer
Dim cc, result, sum, suml, bound, R As Single
Dim p(1 To 2, 1 To 2), p1(1 To 2, 1 To 2) As Single
Dim q(1 To 2) As Single
Dim s(1 To 2) As Single
Dim s1(1 To 2) As Single
Dim N, M, i, j As Integer
N = 2
M = 2
c = 1
result = 0 '赋初值
ni = 0
For i = 1 To N
For j = 1 To M
p(i, j) = InputBox("请输入数据")
Print p(i, j)
Next j
Next i
sum = 0 '赋初值
For j = 1 To M
For i = 1 To N
sum = sum + p(i, j)
Next i
Next j
If sum > 1 Then
Print "!"
c = 1
i = N
End If
c = 0
If c = 1 Then
bound = InputBox(":")
End If
For i = 1 To N
q(i) = 1 / N
Next i
For i = 1 To N
s(i) = q(i)
Next i
For j = 1 To M
s1(j) = 0 '赋初值
For i = 1 To N
s1(j) = s1(j) + s(i) * p1(i, j)
Next i
Next j
For j = 1 To M
For i = 1 To N
p(i, j) = s(i) * p1(i, j) / s1(j)
Next i
Next j
For i = 1 To N
q(i) = 0 '赋初值
For j = 1 To M
If p(i, j) > 0 Then
q(i) = q(i) + p1(i, j) * Log(p(i, j))
q(i) = Exp(q(i))
End If
Next j
Next i
suml = 0
For i = 1 To N
suml = suml + q(i)
Next i
For i = 1 To N
q(i) = q(i) / suml
ni = ni + 1
suml = result
Next i
For i = 1 To N
For j = 1 To M
If p(i, j) > 0 Then
result = result + s(i) * p1(i, j) * Log(p(i, j))
Else
result = 1
End If
Next j
If s(i) > 0 Then
result = result - s(i) * Log(s(i))
End If

Next i
If Abs(result - suml) < bound Then
ok = 1
End If
R = result / Log(2)
If ok = 0 Then
Print ":" & R
End If
End Sub

搜索更多相关主题的帖子: 数据 
2007-04-24 09:06
快速回复:VB的数据溢出,找不到在哪!
数据加载中...
 
   



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

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