返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int a(int x)
  5. {
  6.    if(x==1)
  7.      return 1;
  8.    else
  9.      return x*a(x-1);
  10. }
  11. int main()
  12. {
  13.     int x;
  14.     cout<<"請輸入數字:";
  15.     cin>>x;
  16.     cout<<x<<"階乘為"<<a(x)<<endl;
  17.     system("pause");
  18.     return 0;   
  19. }
複製代碼

TOP

返回列表