#include
void main ()
{
int su[10],ans[10];
int i,j,flag,k = 0;
for (i = 0; i < 10; i ++)
scanf ("%d",&su[i]);
for (i = 0;i < 10; i ++)
{
flag = 1;
else
for (j = 2; j < su[i];j ++)
if (su[i]%j == 0)
{ flag = 0; break;}
if (flag)
ans[k ++] = su[i];
}
for (i = 0;i < k;i ++)
printf ("%d\n",ans[i]);
}
程序如下:
// 该程序作用为查找素数
#include "stdio.h"
#include "math.h"
//#include "conio.h"
void main(void)
{
int shushu(int ); /*the function is solve prime number */
int i;
int c;
int aa[10];
printf("please int the aa[]:");
for(i = 0; i<10; i++)
{
scanf("%d",&aa[i]);
}
for(i= 0; i<10; i++)
{
c=shushu(aa[i]);
if(c==1)
{
printf("the aa[%d]=%d is prime number\n",i,aa[i]);
}
}
// getch();
}
int shushu(int n)
{
int a,i;
if (n <= 1) return(0);
if (n == 2) return(1);
if (n %2 == 0) return(0);
a = sqrt( n )+1;
for (i=3; i<=a; i+=2)
{
if (n%i == 0) return(0);
}
return(1);
}
#include
#include
void main()
{ int m[10],i,k;
printf("please input number:/n")
for(i=0;i<10;i++)
scanf("%d"&m[i]);
k=sqrt(m[i]);
for(i=0;i<10;i++)
{ for(i=2;i<=k;i++)
if(i>k) printf("%d,m[i]");}
}