close
Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中 
Eventbrite makes it happen

Create an event and sell tickets online through Eventbrite. It's simple! Sign up and get started today.
From our sponsors
使用遞迴 因數分解
Sep 17th 2013, 08:04

安安 如題 以下是小弟的答案
可是編譯時 發生 warningC4098 'sk':'void'函式正在傳回值
我將void 改成int sk(int);
發生warningC4715 'sk' 不是所有路徑都傳回值
請大大們幫小弟看看 那裡發生錯誤
#include
void sk(int);
int main(void)
{
int j,n;
printf("輸入你要分解的數字:");
scanf("%d",&n);
for (j=2;j
{
if (n%j==0)
break;
else if (j>=n-1)
printf("%d=1*%d\n",n,n);
}
printf("%d=",n);
sk(n);
printf("\n");
return 0;
}
void sk(int x)
{
int i;
for (i=2;i
{

if (x%i==0)
{
if (x/i==1) {
printf("%d",i);
}
else
{
printf("%d*",i);
return sk(x/i);
}
}
}
}

還有 主程式中這段 else if (j>=n-1)
printf("%d=1*%d\n",n,n);
}
小弟想說 要是判定質數時 就列出1*n
然後結束 可是他還是會跑sk(n);
請問要怎麼敍述 才能不會再跑sk(n);
以上 麻煩大大們解惑

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. Five Filters recommends:

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
    全站熱搜
    創作者介紹
    創作者 nbv2eybn7a7ye 的頭像
    nbv2eybn7a7ye

    進擊的巨人14, 進擊的巨人線上看, 進擊的巨人漫畫, 進擊的巨人遊戲, 進擊的巨人 動畫, 進擊的巨人 線上漫畫, 進擊的巨人14線上看, 進擊的巨人13, 進擊的巨人 h, 進擊的巨人op

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