level 2
hubuabcueu
楼主
#include<stdio.h>
#include<math.h>
main()
{
int a,b,c,d,e,f,h,g,x,y,z;
for(a=0;a==0;)
{
printf("\nplease in put a number like 2,4,6...from 100 to 200\n");
scanf("%d",&b);
if((b%2==1)||(b<100)||(b>200)) printf("illegal number !!!");
else a=1;
}
c=sqrt(b);
for(e=2;e<=c;e++)
{
d=qiu(e);
if(d!=0)
{
f=b%d;
if(f==0) g=b/d;
h=qiu(g);
if(h!=0)
printf("\n%d %d",d,h);
}
}
}
qiu(int x)
{
int y,z;
for(y=1,z=0;y<=x;y++)
{
if(x%y==0) z++;
}
if(z==2) return(x);
else return 0;
}
证明随便输入一个100-200之间的数,都可以写成两个素数的乘积,写完又不知道错哪里了,郁闷,有高手在吗,给指点下吧
2010年12月18日 08点12分
1
#include<math.h>
main()
{
int a,b,c,d,e,f,h,g,x,y,z;
for(a=0;a==0;)
{
printf("\nplease in put a number like 2,4,6...from 100 to 200\n");
scanf("%d",&b);
if((b%2==1)||(b<100)||(b>200)) printf("illegal number !!!");
else a=1;
}
c=sqrt(b);
for(e=2;e<=c;e++)
{
d=qiu(e);
if(d!=0)
{
f=b%d;
if(f==0) g=b/d;
h=qiu(g);
if(h!=0)
printf("\n%d %d",d,h);
}
}
}
qiu(int x)
{
int y,z;
for(y=1,z=0;y<=x;y++)
{
if(x%y==0) z++;
}
if(z==2) return(x);
else return 0;
}
证明随便输入一个100-200之间的数,都可以写成两个素数的乘积,写完又不知道错哪里了,郁闷,有高手在吗,给指点下吧