VB編寫函式,實現計算

2021-03-04 08:54:49 字數 1014 閱讀 5896

1樓:匿名使用者

private sub form_load()for i = 1 to 20

s = s + i ^ 3

next

msgbox s

end sub

vb編寫乙個函式計算通過函式呼叫的方式計算1^4+2^4+3^4+……+n^4 的值

2樓:匿名使用者

private sub ***mand1_click()msgbox sum(3)

end sub

function cf(n as long) as longcf = n ^ 4

end function

function sum(n as long) as longdim result as long

dim i as long

result = 0

for i = 1 to n

result = result + cf(i)next

sum = result

end function

用vb編寫乙個過程,計算1+2∧2+3∧2+4∧2+……+n∧2

3樓:聽不清啊

dim s as long

private sub ***mand1_click()dim n as integer

n = cint(inputbox("n="))sum n

print s

end sub

private sub sum(n as integer)for i = 1 to n

s = s + i * i

next i

end sub

4樓:匿名使用者

subinput n

for i = 1 to n

a=a+i^2

next i

print a

end sub

vb編寫函式計算通過函式呼叫的方式計算1 4 2 4 3 4n 4的值

private sub command1 click msgbox sum 3 end sub function cf n as long as longcf n 4 end function function sum n as long as longdim result as long dim ...

編寫函式mypow函式的功能是計算a的n次方在主函式

include unsigned long long mypow int a,int srs unsigned long long fact int srs int main void printf d 2 d 2 3 d d d 1 2f n x,x,x,n,n,ljs return 0 unsi...

c語言編寫排序函式,實現對主函式中陣列的公升序排序

include void mysort int p,int n int main int argc,char argv i mysort a,10 for i 0 i 10 printf d a i printf n return 0 void bubble sort int a,int n p2 ...