Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中 
Shop Best Buy

Find this week's deals in computers, cameras, phones, and more! Choose store pick up or other shipment options.
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
    全站熱搜
    創作者介紹
    創作者 sdfgdf2 的頭像
    sdfgdf2

    中文名字日文翻譯, 中文翻譯日文名字, 名字日文翻譯, 日文翻譯名字, 日文翻譯字典發音, 日文翻譯網 漢字,

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