mdsk.net
当前位置:首页 >> 用vB编程计算: x%x^3/3!+x^5/5%x^7/7!+… >>

用vB编程计算: x%x^3/3!+x^5/5%x^7/7!+…

Option ExplicitPrivate Sub Form_Click() Dim x#, i&, A#, T#, S#, F# x = InputBox("x = ? ") If x = 0 Then MsgBox "Sin(x)= 0" Exit Sub End If T = x * x A = x S = A F = 1 i = 3 Do F = F * i * (i - 1) A = -A * T S = S + A / F i = i + 2 Loop Until Abs(A / F) < 1E-16 MsgBox "Sin(x)=" & SEnd Sub

Option ExplicitPrivate Sub Form_Click() Dim x#, i&, A#, T#, S#, F# x = InputBox("x = ? ") If x = 0 Then MsgBox "Sin(x)= 0" Exit Sub End If T = x * x A = x S = A F = 1 i = 3 Do F = F * i * (i - 1) A = -A * T S = S + A / F i = i + 2 Loop Until Abs(A / F) 评论0 0 0

#include<stdio.h> void main() { int i,n,k,j; double sum = 0, x; k = 1; x = 2.5; j = 1; n = 2; for(i=1; i<=2*n-1; i += 2) { sum += x * k /j; x = x*6.25; j = j*(i+1)*(i+2); k = -k; } printf("%lf\n", sum); }

'1、r=0 不能进入循环 '2、输入角度后需要化成弧度 '3、变量类型定义错误 Private Sub Form_Click()Dim i, x, s, r, p, n, o, qx = Val(InputBox("输入 X 的值")) * 3.14159 / 180q = 1o = 1s = 0n = 1Don = n + 1r = x ^ q / oIf r < 0.00001 Then Exit Dop = (

1 #include 2 #include 3 #define pi 3.14159265358 4 int main() 5 { 6 double x,n=1; 7 double s = 0,fn; 8 printf("请输入度数:\n"); 9 scanf("%lf",&x); 10 x = x / 180 * pi; 11 while(x > pi) 12 { 13 x -= pi; 14 15 } 16 fn = x; 17 while(fabs(fn) > 0.

Private Sub Command1_Click()Dim a As Longa = jc(3) + jc(5) + jc(7)Print aEnd SubFunction jc(n As Integer) As LongDim i As IntegerDim m As Longm = 1For i = 1 To nm = m * iNextjc = mEnd Function

program main implicit nonereal x,factprint*,"输入x:"read*,xprint*,"sinx=",fact(x)end program function fact(x)implicit nonereal x,fact,hinteger kFACT=X ; H=XK=2DO WHILE(ABS(H)>=1E-6)H=-H*X*X/(K*(K+1))F

sinx=x-x^3/3!+x^5/5!+x^7/7!++(-1)x^(2n-3)/(2n-3)!+(-1)x^(2n-1)/(2n-1)!看不懂!!清楚点好吗?哇!!好科幻呀!头都痛了!搞了两小时都没搞出来!==吧我帮你问高手

公式、算法都是对的. 第一部分有小错误,应该改成: Function fac(m As Integer) fac = 1 For i = 1 To m fac = fac * i Next i End Function 同时下面也应该把p定义为double ,否则容易溢出.

'1、r=0 不能进入循环'2、输入角度后需要化成弧度'3、变量类型定义错误Private Sub AutoRedraw = TrueFontSize = 12Print "输入X,求Sin(X).单击窗体开始计算"End

相关文档
网站首页 | 网站地图
All rights reserved Powered by www.mdsk.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com