#include<stdio.h>
#include<math.h>
int prime(int m)
{
int k,flag=1;
for(k=2;k<(int)sqrt((double)m);k++)
if(m%k==0)
flag=0;
return flag;
}
int fun(int n,int *x,int *y)
{
int k,flag=0;
for (k = 2; k <=(int) sqrt((double)n); k++)
{
if (n % k != 0) //判断k能否可以被n整除
{
continue;
}
if (prime(k) == 0 || prime(n/k) == 0) //判断k和k/n是否为素数,k*(k/n)==n
{
continue;
}
flag = 1; //都满足后赋值
*x = k;
*y = n/k;
break;
}
return flag;
}
main()
{
int a,b;FILE *out ;
out = fopen("out.dat","w") ;
if(fun(111,&a,&b)) {
printf("111=%d*%d\n",a,b);
fprintf(out, "111=%d*%d\n",a,b);
}
if(fun(11111,&a,&b)) {
printf("11111=%d*%d\n",a,b);
fprintf(out, "11111=%d*%d\n",a,b);
}
if(fun(1111111,&a,&b)) {
printf("1111111=%d*%d\n",a,b);
fprintf(out,"1111111=%d*%d\n",a,b);
}
fclose(out);
getchar();
}
04-13
3097
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
08-14
741
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
08-16
301
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
08-17
279
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)