返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int hie(int root,int result)
  5. {
  6.     int total=result;
  7.     if(root>0)
  8.     {
  9.         total=total*root;
  10.         root--;
  11.         return hie(root,total);
  12.     }
  13.     else
  14.     {
  15.         return total;
  16.     }
  17. }
  18. int main()
  19. {
  20.     int num;
  21.     cout<<"輸入要階層的數:"<<endl;
  22.     cin>>num;
  23.     cout<<num<<"階是"<<hie(num,1)<<endl;
  24.     system("pause");
  25.     return 0;
  26. }
複製代碼

TOP

返回列表