编写一个计算阶乘的函数fac(3)

2020-03-27 07:16

printf(“yes”) else

printf(“no”)

}

23. #include

float max(floata, float b) {float t=a

if(b>t)t=b return t } main() {float a,b,c

printf(“Input a,b,c:”)

scanf(“%f%f%f”,&a&b&c) printf(“%f”,max(max(a,b),c)) }

24. #include

float min(int a,int b,int c) {float temp

if(a>b) {

temp=a b=temp a=b; } if(a>c) {

temp=a c=temp a=c; }

return a } main() {

float x,y,z,s

scanf(“%f%f%f”,&x&y&z) s=min(x,y,z)

printf(“the smallest number is %f”,s) }

25. #include long fac(int n) {

long s=1;

int i;

for(i=1;i<=n;i++) s=s*i return s;

}

main() { int j

int sum=0

for(j=1;j<=10;j++) sum=sum+fac(j)

printf(“\\nThe sum is ”,sum); }

26. #include float s(int a,int b) {float s

s=a*b/2.0 return s }

main() { int a,b

float area

float s(int a,int b)

scanf(“%d%d”,&a&b) area=s(a,b)

printf(“ %.2f”,area) }

27. #include #define PI 3.14 float area(int r) {

float s s=PI*r*r return s }

main() { int r float s

printf(“\\nEnter r :”) scanf (“%d”,&r) s=area(r)

printf(“ %.2f”,s) }

28. #include float fun(float p,int n) {

float s if(n<10) s=p*n else

if(n>=10&&n<20) s=p*n*0.9 else

if(n>=20) s=p*n*0.8 return s } main() {

int n float p float sum

printf(“\\nEnter p,n :”) scanf (“%f%d”,&p&n) sum=fun(p,n)

printf(“%.2f”,sum) }

29. #include

int right_triangle(int a,int b,int c) {int temp

if(c>a) {

temp=c c=a; a=temp } if(c

temp=c c=b; b=temp }

if(a*a+b*b==c*c) return 1 else return 0 }

main() {

int x,y,z,s

printf(“\\nEnter x,y,z :”)

scanf(“%d%d%d”,&x&y&z) s= right_triangle (x,y,z) if(s==1)

printf(“yes”) else

printf(“no”) }

30. #include int f(int a,int b) {

int i,temp if(a

temp=a a=b b=temp }

for(i=a;i<=a*b;i++) if(i%a==0&&i%b==0) {

return i break } } main() {

int m,n,s

printf(“\\nEnter m,n:”) scanf(“%d%d”,&m&n) s=f(m,n)

printf(“%d”,s) }

31. #include main()

{int a,b,c; int t; clrscr();

scanf(“%d%d%d”,&a,&b,&c); if(a

if(b

printf(“MMM”,a,b,c); 32.main()

{inta,b,c;flaot ave,sum=0;

scanf(“%d%d%d”,&a,&b,&c); sum=a+b+c ave=sum/3

printf(“%f%f”,ave,sum);} 33. #include #include

float perimeter(int m,int n) {double x,y,z; x=m*m+n*n

y=sqrt((double)x); z=m+n+y return z;} main() {int a,b; float l;

float perimeter(int a,int b); scanf(“%d%d”,&a,&b); l= perimeter(a,b); printf(“%.2f”,l); }

34. #include #define PI3.14159 main() {floatr,h,v;

scanf(“%f%f”,&r,&h); v=PI*r*r*h;

printf(\\n%8.2f,v); }

35. #include main()

{float a,b,h,s;

scanf(“%f,%f,%f”,&a,&b,&h); s=(a+b)*h/2.0;

printf(“\\n%8.2f”,s); }

36. #include #define N 10 main() {

int i,j,a[N],sum=0,count;


编写一个计算阶乘的函数fac(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:药物分析模拟试卷(二) - 答案[2]

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: