1樓:匿名使用者
判斷一個整數是否為素數的通用過程:
dim i as integer
prime = true
for i =2 to sqr(n)
if n mod i =0 then prime = false exit for end ifnext i100以內的素數:for i = 100 to 2 step -1 if prime (i) then redim preserve s(k) s(k)=i k=k+1 ene ifnext i5個一行輸出:private sub command1_() dim i as integer , j as integer randomize for i = 1 to ubound(a) for j = 1 to 5 a(i,j)=i form1.
print a(i,j) next j from1.print next iend sub
2樓:匿名使用者
private sub command1_click()dim i as long, count as longfor i = 3 to 100
if isprime(i) then
print i;
count = count + 1
if count mod 4 = 0 then printend if
next i
end sub
public function isprime(n as long) as boolean
dim mark as boolean
dim i as long
if n < 2 then
isprime = false
exit function
end if
for i = 2 to n - 1
if n mod i = 0 then
mark = true
exit for
end if
next i
isprime = not mark
end function
3樓:匿名使用者
private sub form_click()dim n as integer
for i = 3 to 100
for j = 3 to sqr(i)
if i mod j = 0 then exit fornext j
if j > sqr(i) then
print i;
n = n + 1
if n = 4 then
n = 0
end if
end if
next i
end sub
如何用j**a編寫程式,找出50~100之間的所有素數?
4樓:匿名使用者
public class a
}if(isprime)}}
} -----------testing
53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
vb編寫程式找出3~100間所有素數並輸出窗體
5樓:匿名使用者
private sub command1_click()dim s as long, x as longfor s = 3 to 100
if zhi(s) then x = x + 1: print snext
print "共 " & x & "個質數"
end sub
private function zhi(x as long) as boolean
dim b as single, i as long, f as long
for i = 2 to x - 1
if x mod i = 0 then
f = 1: exit for
end if
next
if f = 1 then zhi = false else zhi = true
end function
6樓:岔路程式緣
private sub form_click()dim n as integer
dim i as integer
dim j as integer
dim s as boolean
n = 0
for i = 3 to 100
s = true
for j = 2 to sqr(i)
if i mod j = 0 then
s = false
exit for
end if
next
if s then
print format(i, " 0# ");
n = n + 1
if n mod 10 = 0 then printend if
next
print "從3-100之間共有以上"; n; "個素數"
end sub
7樓:聽不清啊
private sub command1_click()for i = 3 to 100
for j = 2 to sqr(i)
if i mod j = 0 then exit fornext j
if i mod j <> 0 then
print i,
k = k + 1
if k mod 5 = 0 then printend if
next i
end sub
編寫一個程式,輸出3-100之間的所有素數,並且每10個一行求.python程式設計方法
8樓:匿名使用者
def is_prime(n):
i = 2
while(i < n):
if n % i == 0:
break
i += 1
if n == i:
return true
else:
return false
p = 0
for i in range(3,101):
if is_prime(i):
print i,
p += 1
if p % 10 == 0:
print '\n'
麻煩用c語言解決下這2道題 1.編寫一個程式,輸出3到100之間的素數,要求每10個一行
9樓:匿名使用者
1.編寫一個程式,輸出3到100之間的素數,要求每10個一行#include
#include
int prime(int number)}return flag;
}void main()
if(k==10)}}
2.從鍵盤上輸入若干個學生某門課程的成績,計算出平均成績,並輸出低於60分的學生成績,當輸入負數時結束輸入
#include
#define max 20
void main()
else break;
}printf("平均成績為: %.2f\n",(float)s/n);
printf("低於60分的學生成績為: \n");
for(int i=0;i if(score[i]<60) printf("%d\n",score[i]);} 介面你自己設計 我幫你寫 等一下附上來 dim s as integer private sub command1 click 開始按鈕timer1.interval 1000timer1.enabled trueend sub private sub command2 click 停止按鈕time... include int main 用j a編寫程式,求解一下分段函式。要求輸入x的值,輸出函式y的值。x 5 class fun public int y int x else if x 0 else if x 0 x 10 else return 0 在c語言中怎麼將分段函式 y x 1 5 if... include 主函式 main s是字元指標抄 陣列。對應4個字串襲。迴圈中bai i 3 2 1 0 對於不同的i,j有不同取值du 3 第一zhi次判斷就不成立,直接退出dao。不做操作 2 j 3 1 j 3 2 0 j 3 2 1 輸出的是s i j 也就是 從s i 字串的第j個字元開始...用VB編寫程式利用計時器計時,在窗體上新增命令按鈕,標籤,計時器控制元件,注意 在Timer的事
編寫程式求解分段函式,編寫程式 求解分段函式 y x 5 x 0 ,y x 1 x 0 ,y x 1 0 x 10 ,y 100 其他
編寫程式,求10用c語言,編寫程式,求10用C語言