See the full set of "C language problem sets"
Topic:
Decomposes a positive integer into decomposition. For example: Enter 90, print out 90=2*3*3*5.
Program analysis: N to decompose decomposition, you should find a minimum prime number k, and then complete the following steps:
(1) If this prime number is equal to n, then the process of decomposing decomposition is finished and printed out.
(2) if n<>k, but n can be divided by K, you should print out the value of K, and n divided by the quotient of K, as a new positive integer you n, repeat the first step.
(3) If n cannot be divisible by K, then repeat the first step using k+1 as the value of K.
2. Program Source code:
#include "stdio.h"
#include "conio.h"
Main ()
{
int n,i;
printf ("\nplease input a number:\n");
scanf ("%d", &n);
printf ("%d=", N);
for (i=2;i<=n;i++)
while (n!=i)
{
if (n%i==0)
{
printf ("%d*", I);
n=n/i;
}
Else
Break
}
printf ("%d", n);
Getch ();
}
3.Visual C + + 6.0 debugging pass, as shown in figure: