C语言【微项目02】—整数分解器(采用质数相乘法分解)
【TDTX】
IntfAndpfm.c
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,a0;
int i,t = -1;
int k = 0;
scanf("%d",&a);
a0 = a;
printf("%d = ",a);
for(i = 2;;)
{
if(a0 % i == 0)
{
t = a0 / i;
printf("%d*",i);
a0 = t;
i = 1;
}
if(t == 1)
{
break;
}
if(i < 3)
{
++i;
}
else
{
++i;
++i;
}
}
printf("\b \n\n");
system("pause");
return 0;
}
运行结果示例
------------------------------------------------------第二次发项目类文章有点激动啊!-----------------------------------------------------
-----------------------------------------------------【C语言—微项目—自编练习】------------------------------------------------------
----------------------------------------------------------------【TDTX】-----------------------------------------------------------------