我請問有關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.