FreeBasic打印100之內的素數

dim as integer n,i,f
for n=2 to 100
	f=1
    for i=2 to n\2
		if n mod i=0 then f=0:exit for
	next i
	if f=1 then ?n,
next n
print
sleep
end

輸入p(這裏是5)個整數求平均值code

dim as integer a 
dim as integer s=0
dim as integer p=0
dim as single m
while  p < 5
    print "input score" 
    input a
	s=s+a
	p+=1
wend
m=s/p
print "avrage score is:";m

在Gambas中代碼是這樣的:input

' Gambas module file

Public Sub Main()
 Dim a, s, p As Integer 
 Dim m As Single
 
Let a = 0 
Let s = 0
Let p = 0

While p < 5
    Print "input score" 
    Input a
	s = s + a
	p += 1
Wend
m = s / p
Print "avrage score is:"; m

End
相關文章
相關標籤/搜索