6 8 簡單階乘計算

2021-09-11 03:04:07 字數 554 閱讀 6494

6-8 簡單階乘計算 (10 分)

本題要求實現乙個計算非負整數階乘的簡單函式。

int factorial( const int n );
其中n是使用者傳入的引數,其值不超過12。如果n是非負整數,則該函式必須返回n的階乘,否則返回0。

#include int factorial( const int n );

int main()

/* 你的**將被嵌在這裡 */

5
5! = 120
#define _crt_secure_no_warnings

#include int factorial(const int n);

int main()

int factorial(const int n)

return result;

}

6 8 簡單階乘計算 10 分

本題要求實現乙個計算非負整數階乘的簡單函式。函式介面定義 int factorial const int n 其中n是使用者傳入的引數,其值不超過12。如果n是非負整數,則該函式必須返回n的階乘,否則返回0。裁判測試程式樣例 include intfactorial const int n int ...

6 8 簡單階乘計算 10point s c

本題要求實現乙個計算非負整數階乘的簡單函式。int factorial const int n 其中n是使用者傳入的引數,其值不超過12。如果n是非負整數,則該函式必須返回n的階乘,否則返回0。include int factorial const int n int main 你的 將被嵌在這裡 ...

4 8 簡單階乘計算

本題要求實現乙個計算非負整數階乘的簡單函式。函式介面定義 int factorial const int n 其中n是使用者傳入的引數,其值不超過12。如果n是非負整數,則該函式必須返回n的階乘,否則返回0。裁判測試程式樣例 include int factorial const int n int...