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
相关文章
相关标签/搜索