close
Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中 
Looking for something light while keeping you safe and comfortable during extended waterside activities?

Shop New Drainmaker Shoe for Men, Women and Kids at Columbia!
From our sponsors
程式設計 生日問題
Dec 8th 2013, 21:38

我請問有關C++的問題
題目是 說寫出程式 算出一個團體從 2人 到 20人中, 有兩人或以上會有生日同一天的機率
我的程式如下
#include <iostream>
#include <iomanip>
#include <cmath>
unsigned long factorial(unsigned long);
using namespace std;
int main()
{
int n;
cout <<"請輸入總人數";
cin >> n;
cout<<"此"<<n<<"人中有兩人或以上會有生日同一天的機率為"<<1-((factorial(365)/factorial(365-n))/pow(365,n))<<fixed<<setprecision(2)<<endl;
system("pause");
}
unsigned long factorial(unsigned long num)
{
unsigned long x=1;
for(int i=num; i>=1; i--)
x*=i;
return x;
}
我覺得我這樣寫應該是沒錯啊 但是編譯不出來
可以幫我修改並告訴我錯在哪裡嗎 謝謝喔 感恩

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

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

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