vb程式設計計算,VB程式設計計算 1 2

2021-05-22 12:24:28 字數 5551 閱讀 5913

1樓:匿名使用者

private sub command1_click()dim i as integer, j as integerdim l as long, h as longfor i = 1 to 10

h = 1

for j = 1 to i

h = h * j

next

l = l + h

next

print l

end sub

2樓:岔路程式緣

private sub form_click()

form1.autoredraw = true

me.show

dim sum as long, i as integer, j as integer

sum = 0

for i = 1 to 10

sum = sum + jc(i)

next

print "s=1+2!+3!+...+10!="; sum

end sub

private function jc(x as integer) as long

if x = 1 then jc = 1 else jc = x * jc(x - 1)

end function

或(do while loop ):

private sub form_click()

form1.autoredraw = true

me.show

dim sum as long, i as integer, j as integer

sum = 0

i=1do while i <= 10

sum = sum + jc(i)

i=i+1

loop

print "s=1+2!+3!+...+10!="; sum

end sub

private function jc(x as integer) as long

if x = 1 then jc = 1 else jc = x * jc(x - 1)

end function

3樓:亓靖瀅

dim i as integer

dim sum as integer

dim n as integer

n = 1

sum = 0

for i = 1 to 10

n = n * i

sum = sum + n

next

print(sum)

4樓:宿思敏羿宣

vb程式設計計算2+2^1+2^2+2^3+......+2^10private

subcommand1_click()

dimi%,s%s

=2fori=1

to10s=

s+2^

inext

iprint

send

subvb程式設計求出100-200以內的同時能被3和5整除的所有整數private

subcommand1_click()

dimi

asinteger

fori

=100

to200ifi

mod3=0

andi

mod5=0

then

print

i;end

ifnext

iend

subvb程式設計計算1-2+3-4+5-6……+-n,其中n由文字框輸入

private

subcommand1_click()

dimi%,

k%,s%k=

1fori=

1toval(text1.text)s=

s+i*

kk=-k

next

iprint

sendsub

vb 編寫計算 n! 的子過程,呼叫該過程,計算1!+2!+3!+……+10!之和(10分) 掌

5樓:聽不清啊

private sub command1_click()s = 0

for i = 1 to 10

s = s + fac(i)

next i

print "1!+2!+3!+...+10!="; send sub

function fac(n)

f = 1

for i = 2 to n

f = f * i

next i

fac = f

end function

c語言程式設計計算1!+2!+3!+……+10!的值。

6樓:前程

main()

printf("%d\n",sum);}

7樓:綠布大王

#include "stdio.h"

void main()

printf("%d",sum);}

8樓:匿名使用者

#include

void main()

printf("\b=%d\n",s);}

9樓:薄紙

int x = 1;

for (int i=2; i<10; ++i)

printf("1*...*10 = %d", x);

10樓:

main()

printf("%ld\n",sum);}

11樓:賊寇在何方

#include

using namespace std;

void main()

{int i,n=1,sum=0;

for(i=1;i<=3;i++)

n*=i,sum+=n;

cout<<"1!+2!+···+10!="<果1!+2!+···+10!=4037913

//不錯吧?!

12樓:黑於黥香

#include

void main()

sum = sum + n;

}printf("%d",sum);}

13樓:茳小文

private sub form_click()form1.fontsize = 26

dim a

sum= 0

for i = 1 to 10 stept 1s=0for j =1 to i

s=s+j

next

sum =sum +s

print sum

end sub

vb程式設計計算1+1/2!+1/3!+1/4!+1/5!的值

14樓:哪呢

private sub command1_clickdim s as integer, i as integer, c as integer

s=0c=1

for i =1 to 5

c=c*i

s=s+i/c

next i

15樓:會飛滴包子

private sub command1_click()n=inputbox("請輸

入n:")

dim a as integer

a = 1

dim sum as double

for i = 1 to n

for j = 1 to i

a = a * j

next

sum = sum + 1 / a

a = 1

next

print sum

end sub

vb程式設計,求1!+2!+3!+…+20!。謝謝!

16樓:匿名使用者

第一個文字框(要求填入多少由你決定)

for i = 1 to text1.textb = b +i

next i

text2.text= b

將結果輸出到文字框二

17樓:鬱渟

sub test()

dim i as integer, x as double, y as double

x = 1

y = 0

for i = 1 to 20

x = x * i

y = y + x

next

msgbox y

end sub

18樓:牛人影視

privae sub command1_click()dim i as integer,s as longfor i=1 to 20

s=s+jc(i)

next i

msgbox s

end sub

private function jc(x as integer) as long

dim i as integer

jc=1

for i=1 to x

jc=jc*i

next i

end function

19樓:匿名使用者

n=20

s=0j=1

for i= 1 to n

j=j*i

s=s+j

next

msgbox s

20樓:匿名使用者

樓下的 回答 都挺好的.. 就是靠迴圈哦~~

vb編寫程式計算1+2!+3!+4!+……+10!的程式

21樓:匿名使用者

function jc(n as integer) as longdim i%

jc = 1

for i = 1 to n

jc = jc * i

next

end function

private sub command1_click()dim sumadd as long, i%for i = 1 to 10

sumadd = sumadd + jc(i)next

print sumadd

end sub

22樓:匿名使用者

private sub form_click()s = 1

for i = 2 to 10

s = s + jiecheng(i)

next i

print s

end sub

function jiecheng(a)

t = 1

for i = 2 to a

t = t * i

next i

jiecheng = t

end function

VB程式設計計算s123,VB程式設計計算s

function ss tos as integer as integer tos參與復計算 制的最後一個數 dim i as integer ss 0 for i 1 to tos if i mod 2 0 then ss ss i else ss ss i end if next end fun...

vb程式設計計算三角形面積,VB 程式設計計算三角形面積

在窗體中做4個文字框和一個命令按鈕,如下 private sub command1 click a val text1.text b val text2.text c val text3.text if a b c and b a c and c a b then p a b c 2 s sqr p...

vb題 程式設計計算100以內素數的和

private sub command1 click dim i as integer,j as integer,k as integer for i 2 to 100 for j 2 to i if i mod j 0 then exit for end if next if i j then k...