发布网友 发布时间:2022-04-23 14:15
共1个回答
热心网友 时间:2023-10-17 22:48
用伪代码不好写,我用C语言写。 1. main() {float num,max,n=1; printf("please input a number:\n"); scanf("%f",&num); max=num; while(n<=9) {printf("please input a number:\n"); scanf("%f",&num); if (num>max) max=num; n++; } printf("the max=%f\n",max); } 2. main() {float a,b,c,t; printf("please input three numbers:\n"); scanf("%f%f%f",&a,&b,&c); printf("before sort:a=%g,b=%g,c=%g\n",a,b,c); if(a>b) {t=a;a=b;b=t;} if(a>c) {t=a;a=c;c=t;} if(b>c) {t=b;b=c;c=t;} printf("after sort:a=%g,b=%g,c=%g\n",a,b,c); } 3. main() {int m,n,answer1,answer2; printf("please input two integer numbers:\n"); scanf("%d%d",&m,&n); for(answer1=m;;answer1--) if(m%answer1==0&&n%answer1==0) break; for(answer2=m;;answer2++) if(answer2%m==0&&answer2%n==0) break; printf("the greatest common divisor is %d\n",answer1); printf("the lease common multiple is %d\n",answer2); } 4. #include "math.h" main() {float a,b,c,x1,x2,disc,p,q; printf("please input a,b,c:\n"); scanf("%f%f%f",&a,&b,&c); printf("%.2f*x*x+%.2f*x+%.2f=0\n",a,b,c); disc=b*b-4*a*c; printf("the radix answer is:\n"); if(disc>0) {x1=(-b+sqrt(disc))/(2*a);x2=(-b-sqrt(disc))/(2*a); printf("X1=%.2f,X2=%.2f\n",x1,x2);} else if(disc==0) {x1=x2=(-b)/(2*a);printf("X1=%.2f,X2=%.2f\n",x1,x2);} else {p=-b/(2*a);q=sqrt(-disc)/(2*a); printf("X1=%.2f+%.2fi,X2=%.2f-%.2fi\n",p,q,p,q);} }
希望采纳
热心网友 时间:2023-10-17 22:48
用伪代码不好写,我用C语言写。 1. main() {float num,max,n=1; printf("please input a number:\n"); scanf("%f",&num); max=num; while(n<=9) {printf("please input a number:\n"); scanf("%f",&num); if (num>max) max=num; n++; } printf("the max=%f\n",max); } 2. main() {float a,b,c,t; printf("please input three numbers:\n"); scanf("%f%f%f",&a,&b,&c); printf("before sort:a=%g,b=%g,c=%g\n",a,b,c); if(a>b) {t=a;a=b;b=t;} if(a>c) {t=a;a=c;c=t;} if(b>c) {t=b;b=c;c=t;} printf("after sort:a=%g,b=%g,c=%g\n",a,b,c); } 3. main() {int m,n,answer1,answer2; printf("please input two integer numbers:\n"); scanf("%d%d",&m,&n); for(answer1=m;;answer1--) if(m%answer1==0&&n%answer1==0) break; for(answer2=m;;answer2++) if(answer2%m==0&&answer2%n==0) break; printf("the greatest common divisor is %d\n",answer1); printf("the lease common multiple is %d\n",answer2); } 4. #include "math.h" main() {float a,b,c,x1,x2,disc,p,q; printf("please input a,b,c:\n"); scanf("%f%f%f",&a,&b,&c); printf("%.2f*x*x+%.2f*x+%.2f=0\n",a,b,c); disc=b*b-4*a*c; printf("the radix answer is:\n"); if(disc>0) {x1=(-b+sqrt(disc))/(2*a);x2=(-b-sqrt(disc))/(2*a); printf("X1=%.2f,X2=%.2f\n",x1,x2);} else if(disc==0) {x1=x2=(-b)/(2*a);printf("X1=%.2f,X2=%.2f\n",x1,x2);} else {p=-b/(2*a);q=sqrt(-disc)/(2*a); printf("X1=%.2f+%.2fi,X2=%.2f-%.2fi\n",p,q,p,q);} }
希望采纳