Re: [問題] 新手的小問題
/* 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
討論串 (同標題文章)
完整討論串 (本文為第 3 之 3 篇):
1
6
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章