返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int rec(int x)
  5. {
  6.     if(x==1)
  7.         return 1;
  8.     else
  9.         return x*rec(x-1);   
  10. }
  11. int main()
  12. {
  13.     int n;
  14.     cout<<"想計算幾階乘? ";
  15.     cin>>n;
  16.     cout<<n<<"!="<<rec(n)<<endl;
  17.     system("pause");   
  18.     return 0;
  19. }
複製代碼
Ivy

TOP

返回列表