返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int total(int a)
  5. {
  6.      int res=1;
  7.      for(int i=1;i<=a;i++)
  8.      {
  9.         res*=i;     
  10.      }
  11.      return res;
  12. }
  13. int main()
  14. {
  15.     int n=0;
  16.     cout<<"請輸入階層數"<<endl;
  17.     cin>>n;
  18.     cout<<n<<"!="<<total(n)<<endl;
  19.     system("pause");
  20.     return 0;
  21. }
複製代碼

TOP

返回列表