Re: [問題] 新手的小問題

看板C_and_CPP (C/C++)作者 ( )時間16年前 (2009/08/11 02:14), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
/* CPP: 簡易階層運算 */ #include <iostream> using namespace std; int main() { while(1) { int i = 0, input, result = 1; cout << "Please Input An Integer Here: "; cin >> input; if (input < 0 || input > 17) cout << "Warning: Out of Range!!!" << endl; else { while (i < input) result *= (input - i++); cout << "The Value of F(" << input << ") = " << result << endl; } } return 0; } 數字大於16就得要換個寫法囉 QQ 應該還有更好的版本 :p 數值驗證: http://www.google.com.tw/search?hl=zh-TW&q=10! http://www.google.com.tw/search?hl=zh-TW&q=20! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.57.132.240
文章代碼(AID): #1AW6E66V (C_and_CPP)
文章代碼(AID): #1AW6E66V (C_and_CPP)