Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中 
c語言 質因數分解
Dec 28th 2014, 04:15

以下是我的程式碼,前面除2,除3還可以,但不知為何for迴圈以後的部分總是怪怪的...
#include
#include
#include
int main()
{
unsigned long long int n,r,k,j,q,i;
int pow;
j=i+1;
q=i+5;
r=2;
k=3;
begin:
pow=0;
scanf("%I64d",&n);
int tme,duration;
tme = clock();
//除2
while(!(n%2)){
n=n/2;
pow++;
}
if(pow)printf("%I64d(^%d)*",r,pow);
if(n==1)printf("\b ");
//除3
pow=0;
while(!(n%3)){
n=n/3;
pow++;
}
if(pow)printf("%I64d(^%d)*",k,pow);
if(n==1)printf("\b ");

for(int i=6;;i+=6) {
//除 7,13...
pow=0;
while(!(n%j)){
n=n/j;
pow++;
}
if(pow)printf("%I64d(^%d)*",j,pow);
if(n==1){printf("\b ");break;}
//除 11,17...
pow=0;
while(!(n%q)){
n=n/q;
pow++;
}
if(pow)printf("%I64d(^%d)*",q,pow);
if(n==1){printf("\b ");break;};}

printf("\n");
duration = clock()-tme;
printf( "\n%d milliseconds.\n", duration); system("pause");
goto begin;
}

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 kkoki0httzobg 的頭像
    kkoki0httzobg

    線上遊戲排行榜2013/2014,進擊的巨人線上看,candy crush saga外掛,正妹寫真三圍

    kkoki0httzobg 發表在 痞客邦 留言(0) 人氣()