a010.
因數分解
| From: [120.96.54.37] |
發表日期
:
2014-02-19 10:51
#include<stdio.h>
#include<stdlib.h>
int number,row;
int cit()
{
int k;
for(k=2;k<=number;k++)
{
if(number%k==0 && k<number) {row=0;return 0;}
else if(number%k==0 && number==k){row=1;return 1;}
}
}
void check(int onec)
{
printf("^");
printf("%d",onec);
}
void dpp()
{
printf(" * ");
}
void airplain()
{
int once=0,half;
for(half=2;half<=number;half++)
{
while(number%half==0)
{
if(once==0)printf("%d",half);
number/=half;
once++;
}
if(once>1)
{
check(once);
}
if(number!=0 && number>half&&once>0)dpp();
once=0;
}
}
main()
{
while(scanf("%d",&number)!=EOF)
{
if(cit()==1)printf("%d",number);
if(row==0)
{
airplain();
}
}
}