using System;
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication17
{
class Program
{
static void Main(string[] args)
{
int a, b;
for (a = 2; a < 100; a++)
{
for (b = 2; b < a+1; b++)
{
if (a % b == 0)
{ if (b != a)
break;
else
Console.WriteLine(a);
}
}
}
}
}
}
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication17
{
class Program
{
static void Main(string[] args)
{
int a, b;
for (a = 2; a < 100; a++)
{
for (b = 2; b < a+1; b++)
{
if (a % b == 0)
{ if (b != a)
break;
else
Console.WriteLine(a);
}
}
}
}
}
}
在c++ dev5.0下
#include<iostream.h>
using namespace std ;
int main()
{
int a, b;
for(a=2;a<100;a++)
{
for(b=2;b<a+1;b++)
{
if(a%b==0)
{
if(b!=a)
break ;
else
//printf("素数....%d ",a );
cout<< a;
cout<<"....\n";
}
}
}
// for(;;) {cout<<"素数......\n"; }
system("pause");
return 0;
}