返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int rec(int y)
  5. {
  6.     if(y==1)   
  7.         return 1;
  8.     else
  9.         return y*rec(y-1);
  10. }

  11. int main()
  12. {
  13.     re:
  14.     int y;
  15.     cout<<"請輸入階層運算的值: ";
  16.     cin>>y;
  17.     cout<<y<<" 階層的運算結果值為 "<<rec(y)<<endl<<endl;
  18.     goto re;
  19.     system("pause");
  20.     return 0;
  21. }
複製代碼

TOP

返回列表