用VB求数列1 2 2 3 3 5 5 8 8 13 ...前20项之和
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/12 07:25:30
vb具体语法不会啊.大致用pascal写一下把a=1;b=1;whilei再问:你这里么用wend哇!我先试试看你能不能做出来!再答:pascal里的循环语句和vb不一样,没有wend。。。我用vb写
PrivateSubCommand1_Click()a=2b=1Dot=a/bs=s+tc=aa=a+bb=cn=n+1LoopUntiln=20PrintsEndSub再问:那我还想问下求1-1/2
添加一个文本框输入前N项的N值,再添加一个命令按钮即可PrivateFunctionF(NAsLong)AsLongIfN>2ThenF=F(N-1)+F(N-2)ElseF=1EndIfEndFun
PrivateFunctionGetNum(ByValiCountAsLong)DimiAsLongReDima(iCount)AsLonga(1)=1:a(2)=2:a(3)=3Fori=4ToiC
dimf()asdoublen=inputbox("in","NO.")redimf(n)asdoublef(1)=1f(2)=1fori=3tonf(i)=f(i-1)+f(i-2)nextprin
#include#includemain(void){intn,i;printf("请输入n的值\n");scanf("%d",&n);intsum1=1,sum2=2,sum;for(i=3;i
functionsum(nasinteger)dima(30)asintegerdimsasintegers=0a(1)=0a(2)=0a(3)=1fori=4to30a(i)=a(i-1)+a(i-
DimnAsIntegerDimmAsIntegerDimiAsIntegerDimjAsIntegerDima(30)AsInteger'确定数组的范围()里的数即为最大可储存数+1PrivateS
PrivateSubForm_Click()DimnAsIntegern=Val(InputBox("请输入N:"))Dima,bAsLonga=1:b=1Fori=1TonPrinta&""&b&"
OptionExplicitDimf(40)AsLongPrivateSubCommand1_Click()DimiAsByteDimsAsLongf(1)=1f(2)=1s=2Print"No1:"
简单就是不会再问:....再答:不是不会是好久没做了差不多都忘了呵呵
OptionExplicitDimFileNameAsString'文件名变量PrivateSubForm_Load()DimFilePathAsStringFilePath=App.PathIfRi
非递归:staticvoidf(intn){longp1=1,p2=1,p=1;for(inti=1;i
PrivateSubCommand1_Click()DimS_numAsLongS_num=Val(Text1.Text)Text2.Text=""Text3.Text=""IfS_num>0Then
dimarr,idimn_min,n_max,n_sum,n_avarr="1,2,3,4,5,6,7,8,9,10,11,12"arr=split(arr,",")n_min=clng(arr(0)
大概这个意思:Dim MaxY as SingleDim X,YMaxY = -999999For X = 1
楼上的程序会慢死人的.给一个非递归实现.functionFibonacci(byvalnasLong)asLongdiml1aslong,l2aslong,l3aslongl1=1l2=1ifn
将六个圆命名为“Oval1”直到“Oval6”在窗体上放6个timer控件.写入如下代码:Private Sub Form_load()'必要的初始化操作Timer1.in
PrivateSubCommand1_Click()x=InputBox("请输入x:")e=2.718281828SelectCasexCase-10To-1y=e^x+1Case0To5y=Abs
先写两个数列.PublicSubaa()DimabAsStringDimi,jAsIntegerDima,bAsInteger'素数序列Fori=1To1000Forj=1ToiIfiModj=0An