/*编制程序,输入m、n(m≥n≥0)后,计算下列表达式的值并输出。 要求将计算阶乘的运算编写作函数fact(n),函数返回值的类型为float*/
#include<stdio.h> double fact(int j); int main(void) { int m,n; double s; printf("enter m:"); scanf("%d",&m); printf("enter n:"); scanf("%d",&n); s=fact(m)/(fact(n)*fact(m-n)); printf("s=%.2f\n",s); return 0; } double fact(int j) /*定义阶乘*/
{
int i; double result; result=1; for(i=1;i<=j;i++) result=result*i; return result; }

 

相关文章:

  • 2021-11-08
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-08-23
  • 2022-12-23
  • 2021-08-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
相关资源
相似解决方案