博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
求每个数的质因子
阅读量:7003 次
发布时间:2019-06-27

本文共 503 字,大约阅读时间需要 1 分钟。

ExpandedBlockStart.gif
View Code 
 1 #include <stdio.h>
 2 #include <math.h>
 3 
int find(__int64 n,
int* a)
 4 {
 5 __int64 t=
0,m=n;
 6 
for (
int i=
2;i<=m/
2;i++)
 7 {
 8 
if (n%i==
0)
 9 {
10 a[++t]=i;
11 n/=i;
12 }
13 
while (n%i==
0) n/=i;
14 
if (n==
1
break;
15 }
16 
return t;
17 }
18 
int main()
19 {
20 
int i,l,a[
1000];
21 __int64 n;
22 
while (scanf(
"
%I64d
",&n)!=EOF)
23 {
24 l=find(n,a);
25 
for (i=
1;i<=l;i++)
26 printf(
"
%2d\n
",a[i]);
27 }
28 
return 
0;
29

转载于:https://www.cnblogs.com/modiz/archive/2013/01/10/2855059.html

你可能感兴趣的文章