#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int x,y,time=0;
while(scanf("%d",&x)==1){
while(x%2==0)
{
time++;
x/=2;
}
if(time>1)
printf("2^%d * ",time);
else if(time)
printf("2 * ");
for(y=3;y<=x;y+=2)
{
time=0;
while(x%y==0)
{
time++;
x/=y;
}
if(time>1)
printf("%d^%d * ",y,time);
else if(time)
printf("%d * ",y);
}
printf("\b\b \n");
}
return 0;
在自己的電腦上是對的耶....不解中..
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int x,y,time=0;
while(scanf("%d",&x)==1){
time = 0;
while(x%2==0)
{
time++;
x/=2;
}
if(time>1)
printf("2^%d * ",time);
else if(time)
printf("2 * ");
for(y=3;y<=x;y+=2)
{
time=0;
while(x%y==0)
{
time++;
x/=y;
}
if(time>1)
printf("%d^%d * ",y,time);
else if(time)
printf("%d * ",y);
}
printf("\b\b \n");
}
return 0;
在自己的電腦上是對的耶....不解中..