Form1.AutoRedraw = True
Cls
Dim P15 As Single, P20 As Single, A As Single, Tt As Single
Dim T As Single, P151 As Single, I As Integer
Dim E As Single
E = Exp(1)
T = Val(InputBox("t=", "输入"察喊, 1))
P20 = Val(InputBox("p20=", "输入", 30))
Tt = T
P15 = P20
Print "t="T, "p20="P20
I = 0
Do
I = I + 1
P151 = P15
A = 186.9696 / P15 ^ 2 + 0.4862 / P15
P15 = P20 / E ^ -A * Tt * (1 + 0.8 * A * Tt)
Print I, "p151="P151, "p15="P15
Loop While Abs(P15 - P151) >迅没野= 0.0005
Print "最后结果为:亩喊p15="P15
End Sub
#include <stdio.h>型做#include <math.h>饥戚
float value()
{
float x0, x1
x0 = 0
x1 = cos(x0)
while (abs(x0 - x1) >= 0.000001)
{
x0 = x1
x1 = cos(x0)
}
return x1
}
void main()
{
printf("迭代方法求方程:卜肢衡cos(x)-x=0的解为%f\n", value())
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)