1樓:偵探章邯
'意思就是20個數首尾相連,圍成一個"圓".從第一個數開始,一次取4個數出來求和.找出其中和最大的4個數.
' 1 2 3 4 5 6
' 20 7
' 19 8
' 18 9
' 17 10
' 16 15 14 13 12 11
private sub form_click()
dim i%,n%,a%(19),max%,st$,temp%
me.cls
for i = 0 to 19
a(i) = int(90 * rnd + 10) '20個二位隨機正整數
print a(i); '列印到窗體
next i
for i = 0 to 19
'mod 20 使陣列的下標在[0-19]之間迴圈.使之首尾連線.
temp = a(i) + a((i + 1) mod 20) + a((i + 2) mod 20) + a((i + 3) mod 20) '求四個相鄰數之和
print str(a(i)); " +"; str(a((i + 1) mod 20)); " +"; str(a((i + 2) mod 20)); _
" +"; str(a((i + 3) mod 20)); " = "; temp '列印到窗體
if max < temp then max = temp:n = i '比較大小,賦值max、n
next i
print " max is :"; max '列印max到窗體、四個相鄰數
print " number is :"; a(n); a((n + 1) mod 20); a((n + 2) mod 20); a((n + 3) mod 20)
end sub
private sub form_load()
me.autoredraw = true
me.windowstate = 2
randomize
call form_click
end sub
2樓:匿名使用者
sub test()
dim i as integer, mysum as integerfor i = 20 to 273
if (instr(1, i ^ 0.5, ".") < 1) then mysum = mysum + i ^ 0.5
next
debug.print mysum
end sub
'mysum就是 和
vb中,開方的程式怎麼編寫? 5
3樓:網路asp菜鳥
vb的開2次方函式是sqr()。其他次開方可以使用指數函式exp得到,如要計算x的開3次方:exp(log(x)/3)
4樓:
用 exp(log(x)/n)太麻煩了吧..
直接用 x^(1/n)就行了.n代表開n次方.
編寫程式,輸入一個整數,輸出它的平方,平方根,結果取小數點後兩位
5樓:靜水1號
#include
#include
int main()
6樓:匿名使用者
我做了一個vb的 你看看 滿意請採納 最重要的是定義變數為single 然後用浮點除法
vb編寫程式,通過輸入框輸入一個正整數,將這個整數的平方根通過訊息框返回給使用者,**是什麼?
用vb程式程式設計 輸入一個數字,輸出的是這個數的平方根
用vb程式設計:隨機產生10個0~100之間的隨機整數,存放在一個陣列中,然後求個元素和、平均值,統計
7樓:匿名使用者
private sub form_load()dim a(10), i, x, j as integerdim y as string
for i = 0 to 9
randomize
a(i) = int(rnd(1) * 101)x = x + a(i)
next i
print "元素bai和=" & x
print "平均
du值=" & x / 10
for i = 0 to 9
if a(i) > (x / 10) then j = j + 1: y = y & cstr(a(i)) & " "
next i
print "大於
zhi平dao
均值的元素個回數=" & j
print "大於平均值的元素:答" & yme.refresh
end sub
編寫程式,計算s
下面是你的 修改後並能成功執行的 include main printf s 6f n s getchar getchar 錯誤1.maim改為 main 錯誤2.for迴圈沒加花括號,沒括號只迴圈for接下來的那句。錯誤3.a t不能是整型,至少t不能是整型,想想看,若a t是整型會造成s也是整型...
用vb編寫程式,計算
option explicitdim k,t as singleprivate sub mand1 click for k 2 to 300 step 2t t 1 k next label1.caption t end sub for i 2 to 300 step 2 sum 1 i sum n...
c語言編寫程式計算並輸出,C語言。編寫程式計算並輸出 1 12 123 1234 的前n 設0 n 10 項的和,n從鍵盤輸入。
4歲的帥帥最近感冒了,伴發高燒,流清鼻涕,光波爐菜譜,早晚咳嗽不停,在醫院打了兩天吊針,服過退燒藥和止咳藥,約5天孩子感冒好了,不發燒也不流鼻涕,就是咳嗽不見減輕。事實上,當感冒急性期症狀消失後,咳嗽仍遷延不愈,臨床上稱之感冒後咳嗽。感冒後咳嗽多見7歲以下小兒,症狀表現為剌激性乾咳或咳少量白色黏液痰...