【C语言】第七章 函数(1).pptVIP

  • 9
  • 0
  • 约9.9千字
  • 约 49页
  • 2022-07-22 发布于上海
  • 举报
已知求n!的函数: float jiecheng(int n) { int i; double mul=1; for( i=1;i=n;i++) mul *= i ; return mul ; } 编写程序,求出6!、15!、28! #include stdio.h void main() { printf(“6!=%.0f\n”,jiecheng(6)); printf(“15!=%.0f\n”,jiecheng(15)); printf(“28!=%.0f\n”,jiecheng(28)); } 函数调用例2: 代码复用 float area2(float d) { float s; s=3.14159*(d/2)*(d/2)/2; return(s); } 例 3.求右图图形的面积 。 #include math.h float area1(float a,float b,float c) { float s,p; p=(a+b+c)/2; s=sqrt(p*(p-a)*(p-b)*(p-c)); return(s); } main( ) { float a,b,c,s; sca

文档评论(0)

1亿VIP精品文档

相关文档