level 1
bletchley
楼主
输入了个很大的数,结果他本身就是素数,我还以为程序错了,反复检查,哎......我想问下,为什么exit(0) 那里为什么不能用break来跳出循环啊?
#include "stdio.h"
#include "math.h"
void sushu(int y);
void onetwo(int x)
{
if ((x==1)||(x==2))
printf("%d",x);
else
sushu(x);
}
void sushu(int y)
{
int i;
for (i=2;i<=y;i++)
{
if(y==i)
{
printf("%d",y);
exit(0);
}
if((y%i==0)&&(y!=i))
{
printf("%d*",i);
sushu(y=y/i);
}
}
}
void main()
{
int n;
scanf("%d",&n);
printf("%d=",n);
onetwo(n);
}
2010年02月28日 15点02分
1
#include "stdio.h"
#include "math.h"
void sushu(int y);
void onetwo(int x)
{
if ((x==1)||(x==2))
printf("%d",x);
else
sushu(x);
}
void sushu(int y)
{
int i;
for (i=2;i<=y;i++)
{
if(y==i)
{
printf("%d",y);
exit(0);
}
if((y%i==0)&&(y!=i))
{
printf("%d*",i);
sushu(y=y/i);
}
}
}
void main()
{
int n;
scanf("%d",&n);
printf("%d=",n);
onetwo(n);
}