VERSION 5.00
Begin VB.Form Form1
Caption = "素数"
ClientHeight = 3090
ClientLeft = 5175
ClientTop = 3960
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
Begin VB.PictureBox Picture2
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1455
Left = 960
ScaleHeight = 1395
ScaleWidth = 3555
TabIndex = 1
Top = 1560
Width = 3615
End
Begin VB.PictureBox Picture1
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1335
Left = 960
ScaleHeight = 1275
ScaleWidth = 3555
TabIndex = 0
Top = 120
Width = 3615
End
Begin VB.Label Label2
Caption = " 非素 数区"
BeginProperty Font
Name = "黑体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 240
TabIndex = 3
Top = 1800
Width = 975
End
Begin VB.Label Label1
Caption = "素 数 区"
BeginProperty Font
Name = "黑体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 360
TabIndex = 2
Top = 360
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
Dim N As Single, K As Single, I As Single, j As Integer, l As Integer
l = InputBox("请要输入正整数的个数", "输入", , 6000, 5000)
'If l = "" Then MsgBox "请输入数据", vbOKOnly, "错误"
ReDim a(l) As Integer
For j = 1 To l
a(j) = Val(InputBox("请要输入正整数的个数"))
Next
For j = 1 To l
K = Int(Sqr(a(j)))
For I = 2 To K
If a(j) Mod I = 0 Then Exit For
Next I
Form1.Show
If I > K Then
Picture1.Print Str(a(j))
Else
Picture2.Print Str(a(j))
End If
Next
End Sub
#include
int main()
{
int m,k,i,n=0;
for(m=1;m<=100;m=m+2)
{
k=sqrt(m);
for (i=2;i<=k;i++)
if (m%i==0) break;
if (i>=k+1) {printf("%d",m);n=n+1;}
if (n%5==0) printf("\n");
}
printf("\n");
getch();
return 0;
}
#include
#include
void main()
{
int m,i,k,j=0;
for(m=1;m<=100;m=m+2)
{
k=sqrt(m);
for(i=2;i<=k;i++)
if(m%i==0)
break;
if(i>=k+1)
{
printf("%d ",m);
j++;
if (j%5==0)
printf("\n");jh
}
}
}