Problem Description
Eddy's interest is very extensive, recently he is interested in prime number. Eddy discover the all number owned can be divided into the multiply of prime number, but he can't write program, so Eddy has to ask intelligent you to help him, he asks you to write a program which can do the number to divided into the multiply of prime number factor .
Input
The input will contain a number 1 < x<= 65535 per line representing the number of elements of the set.
Output
You have to print a line in the output for each entry with the answer to the previous question.
Sample Input
11 9412
Sample Output
11 2*2*13*181
Author
eddy
Recommend
JGShining
水题
AC代码:
#include <stdio.h>
int main()
{
int n,i,j,a[100];
while (scanf("%d",&n)!=EOF)
{
i=2;
j=0;
while(i<=n)
{
if(n%i==0)
{
n=n/i;
a[j++]=i;
i=2;
}
else
i++;
}
for (int k=0;k<j;k++)
{
if (k==j-1)
printf("%d/n",a[k]);
else
printf("%d*",a[k]);
}
}
return 0;
}
本文介绍了一个简单的质因数分解程序,该程序能够将输入的整数分解为若干质数的乘积形式,并通过示例展示了如何运行此程序。
1011

被折叠的 条评论
为什么被折叠?



