阅读以下说明及Visual Basic 程序代码,将应填入(n)处的字句写在对应栏内。 [说明] 本程序求3~100之间的所有素数(质数)并统计个数;同时将这些素数从小到大依次写入顺序文件E: \dataout.txt;素数的个数显示在窗体Form1

admin2009-02-15  19

问题 阅读以下说明及Visual Basic 程序代码,将应填入(n)处的字句写在对应栏内。
[说明]
   本程序求3~100之间的所有素数(质数)并统计个数;同时将这些素数从小到大依次写入顺序文件E: \dataout.txt;素数的个数显示在窗体Form1上。
   [Visual Basic 代码]
   Private Sub Command1_ Click ( )
   Dim count as integer, flag as Boolean
   Dim t1 as Integer, t2 as Integer
     (1)  
   Count=0
   For t1=3 to 100
       Flag=Tree
       For t2=2 to Int( Sqr ( t1 ) )
         If  (2)  Then flag=False
       Next t2
         (3)  
       count=(4)  
       write #1, t1
     End if
   Next t1
     (5)  
   Close #1
         End Sub

选项

答案(1) Open "e:\dataout.txt" For Output as #1 (2) t1 mod t2=0 (3) If t2>Int (sqr(t1))Then (4) count +1 (5) Form1.Print "素数个数"; count

解析
转载请注明原文地址:https://kaotiyun.com/show/IojZ777K
0

最新回复(0)