请讲解一下这段代码Dim a,b,c As Single ,i,As Integera = 2 :b = 3:i = 3 Doc =(a + b) / 3 :a = b :b =c :i = i + 1Loop Until c < 0.03TextBox1.Text = i - 1TextBox2.Text = c
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/20 16:07:43
请讲解一下这段代码Dim a,b,c As Single ,i,As Integera = 2 :b = 3:i = 3 Doc =(a + b) / 3 :a = b :b =c :i = i + 1Loop Until c < 0.03TextBox1.Text = i - 1TextBox2.Text = c
请讲解一下这段代码
Dim a,b,c As Single ,i,As Integer
a = 2 :b = 3:i = 3
Do
c =(a + b) / 3 :a = b :b =c :i = i + 1
Loop Until c < 0.03
TextBox1.Text = i - 1
TextBox2.Text = c
请讲解一下这段代码Dim a,b,c As Single ,i,As Integera = 2 :b = 3:i = 3 Doc =(a + b) / 3 :a = b :b =c :i = i + 1Loop Until c < 0.03TextBox1.Text = i - 1TextBox2.Text = c
Dim a,b,c As Single,i As Integer 'vb.net中 定义a,b,c为单精度 ,i为整形变量
a = 2:b = 3:i = 3 '初始赋值
Do 'do 循环
c = (a + b) / 3 ' c变量的值 等于 a+b的和除以3
a = b '将 b赋值给a
b = c '将c值赋值给b
i = i + 1 'i变量每次循环累加1 计算循环次数用的
Loop Until c < 0.03 '直到c值小于0.03 跳出循环
' 第一次循环
' c = (2 + 3) / 3
' a = 3
' b=(a + b) / 3 =1.666666...
'
' 第二次循环
' c = (3 + 1.66666) / 3
' a = 1.66666..
' b=1.55555...
' 以此类推 直到 c