质因数分解:
给出正整数n,请输出将n质因数分解的结果,结果从小到大输出。
例如:输入n=120,程序应该输出2 2 2 3 5 ,表示120=2*2*2*3*5。输入保证2<=n<=10^9。
提示:先从小到大枚举变量i,然后用i不停试除n来寻找所有的质因子。
试补全程序。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include <cstdio> using namespace std; int n,i; int main(){ scanf("%d",&n); for ( i =__1__ ; __2__<=n ; i++){ __3__{ printf("%d ",i); n=n/i; } } if(__4__){ printf("%d",__5__); } } |
0 of 5 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 5 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
1处应填( )
2处应填( )
3处应填( )
4处应填( )
5处应填( )