整数分解问题;(与题uva10392 Factoring Large Numbers类似 这里就不多说了)
对每个可能的因子进行试除;
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int f(int n){
if(n<0)
printf("%d = -1 x ",n);
else printf("%d = ",n);
n=abs(n);
for(int i=2;i<=(int)sqrt(n+0.5);i++){
while(n%i==0){
n/=i;
if(n==1)
printf("%d",i);
else printf("%d x ",i);
}
}
if(n>1) printf("%d",n);
printf("\n");
}
int main(){
int n;
while(scanf("%d",&n)==1){
if(n==0)
break;
f(n);
}
}