æ们ç¨ä¸ä¸ªæ¯è¾æ¶é«¦çåæ³ï¼ç¨é¢å对象ææ³ææ¯ä¸è¡åæä¸ä¸ªç±»ã
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Class Value '声æValue为类
REM ç±»çå
Œ
±æ°æ®
Public Type As String 'ç±»årbææ¯rf
Public ValX As Double '表第äºå
Public ValY As Double '表第ä¸å
Public Sub New(t As String, x As String, y As String) 'æé å½æ°
Type = t 'èµå¼
ValX = x
ValY = y
End Sub
REM ç±»çéææ¹æ³ï¼ç¨æ¥å¾åºç»æx=(12.1+12.4)/2+(12.2+12.3)/2
Public Shared Function SolveX(ByRef Values() As Value) As Double '以ä¸ä¸ªValueæ°ç»ä¸ºåæ°
Dim result1 As Double = 0 '第ä¸ä¸ªå æ°(12.1+12.4)/2
Dim count1 As Integer = 0 'rbç个æ°
For Each v In Values 'éåè¿ä¸ªæ°ç»
If v.Type = "rb" Then 'è¥æ¯rb
result1 += v.ValX 'å
å è¿å»
count1 += 1 '个æ°å ä¸ãä¹å¯ä»¥åæcount1 = count1 + 1
End If
Next
result1 /= count1 'ç®åºç¬¬ä¸ä¸ªå æ°ãä¹å¯ä»¥åæresult1 = result1 / count
Dim result2 As Double = 0 'ä¾æ¤ç±»æ¨ï¼ç®åºç¬¬äºä¸ªå æ°
Dim count2 As Integer = 0
For Each v In Values
If v.Type = "rf" Then
result2 += v.ValX
count2 += 1
End If
Next
result2 /= count2
Return result1 + result2 'è¿å两个å æ°çå
End Function
REM åæ ·ç
Public Shared Function SolveY(ByRef Values() As Value) As Double
Dim result1 As Double = 0
Dim count1 As Integer = 0
For Each v In Values
If v.Type = "rb" Then
result1 += v.ValY
count1 += 1
End If
Next
result1 /= count1
Dim result2 As Double = 0
Dim count2 As Integer = 0
For Each v In Values
If v.Type = "rf" Then
result2 += v.ValY
count2 += 1
End If
Next
result2 /= count2
Return result1 - result2
End Function
End Class
æä¹ä½¿ç¨è¿ä¸ªç±»å¢ï¼
1
2
3
4
5
6
7
8
9
10
11
12
13
Dim values() As Value = {New Value("rb", 12.1, 1.1), _
New Value("rf", 12.2, 1.2), _
New Value("rf", 12.3, 1.3), _
New Value("rb", 12.4, 1.4)} '声æä¸ä¸ªæ°ç»values并ä¸æ¬¡æ¾å
¥4个Value对象
Console.WriteLine("X = {0}", Value.SolveX(values)) 'Value.SolveX(æ°ç»)表示Xç»æ
Console.WriteLine("Y = {0}", Value.SolveY(values)) 'Value.SolveY(æ°ç»)表示Yç»æ
Console.ReadKey()
温馨提示:内容为网友见解,仅供参考
用VB.NET编写一个程序 :编一求阶乘的函数f(n),主调程序求组合数的程序...
用VB.NET编写一个程序 :编一求阶乘的函数f(n),主调程序求组合数的程序,分别调用f(n),用来计算组合数的值 10 组合数公式 n!\/m!(n-m)! “!”表示阶乘 谢啦 我的程序总是提示确保不会除零 我郁闷了。。。 Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e ...
电脑里常用的的英语有那些(汉语意思)?
Data Structures 基本数据结构 Dictionaries 字典 Priority Queues 堆 Graph Data Structures 图 Set Data Structures 集合 Kd-Trees 线段树 Numerical Problems 数值问题 Solving Linear Equations 线性方程组 Bandwidth Reduction 带宽压缩 Matrix Multiplication 矩阵乘法 Determinants and Permanents 行列式 Constrain...
目前网络时间服务有哪几种协议?
TimeFromNet = Mid(TimeFromNet, 17, 8)TimeFromNet = TimeSerial((Hour(TimeFromNet) + 8) Mod 24, Minute(TimeFromNet), Second(TimeFromNet))Time = TimeFromNet '设置系统时间End IfEnd IfElse'为使网络传输误差减小,第2次再取中科院国家授时中心时间NetTime "www.time.ac.cn"If TimeFromNet = "...
C#之父是谁?和详细信息?
三年后,VJ++编译出来的虚拟机械码的执行效率不但比任何的Java开发工具还快,在某些方面甚至比原生的Windows开发工具,例如Delphi、VB、甚至是VC++还有效率。这真是令人震撼,当然Anders为VJ ++打下的基础现在也展现在.NET的C#编译器以及.NET的JIT(Just InTime)编译器之上,.NET的JIT在许多程序代码最佳化方面比Delphi还先...
安德斯·海尔斯伯格的成功路程
这真是令人震撼,当然Anders为VJ ++打下的基础现在也展现在.NET的C#编译器以及.NET的JIT(Just In Time)编译器之上,.NET的JIT在许多程序代码最佳化方面比Delphi还先进。因此在两三年前当VJ++即将推出之际,在Borland内部也引起了非常大的骚动,并且严阵以待,当然这又是另外一个故事了。对于Anders来说,到了Microsoft...