直接用 int 來存只能正常算到 12! 而已 ~
#include <iostream>
using namespace std;
int main(void)
{
int n,sum;
while(sum=1) {
cout << "Please input n to get n! , -1 to exit.....n = ";
cin >> n;
if (n == -1) break;
cout << n <<"! = ";
while(n-- , n>0) sum=sum*(n+1);
cout << sum << "\n";
}
return 0;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.18.117
※ 編輯: whxu 來自: 140.112.18.117 (10/02 15:59)