我想用递归实现合数分解,编译通过,执行错误,还望高手指教
以下是程序代码:#include<stdio.h>
#include<math.h>
#define COUNT 6542
unsigned int zs[COUNT]; //用于存放素数
void qzsf();
void fj();
void qzsf () //求素数,并存放在zs
{
static unsigned int zs[COUNT];
int z = -1;
int i,j;
double k;
for(i = 2;i < 65535;i++)
{
k = sqrt (i);
for(j = 2;j <= k;j++)
if(i%j == 0)
break;
if(j>k)
zs[++z] = i;
}
}
void fj (unsigned num) //用递归输出结果
{
int i;
static unsigned int zs[COUNT];
for(i = 0;zs[i] <= num;i++)
if(num%zs[i] == 0)
{
printf ("%d*",zs[i]);
fj (num%zs[i]);
}
else
{
printf ("%d\n",num);
}
}
main() //调用fj函数,对输入的数分解
{
unsigned int num;
printf ("The number:");
scanf ("%ld",&num);
fj (num);
}