.
1.
A
B
2.
3.
[1]
main()
{
int a,b,c,sum;
float aver;
clrscr(); /**/
printf("Please input three numbers:");
scanf("%d,%d,%d",&a,&b,&c);
sum=a+b+c;
aver=sum/3.0;
printf(“a=%d,b=%d,c=%d \n ",a,b,c);
printf("sum=%d,aver=%7.2f\n",sum,aver);
}
[2]
5c ( F 3 2 )
9
#include "stdio.h"
void main()
{float c,f;
scanf("%f",&f);
c=5.0/9*(f-32);
printf("%.1f\n",c);
}
[3]
#include "stdio.h"
main()
{int a,b,t; /*t */
scanf("%d,%d",&a,&b);
printf("a=%d,b=%d\n",a,b);
t=a;
a=b;
b=t;
printf("a=%d,b=%d\n",a,b);
}
[4]
#include "stdio.h"
#include "math.h"
main()
{float r,area,peri;
scanf("%f",&r);
area=3.14*pow(r,2); /* pow(x,y) xy */
peri=2*3.14*r;
printf("area=%.2f,peri=%.2f\n",area,peri);
}
ax2+bx+c=0b2-4ac>0
(a,b,c)
#include <math.h>
main()
{
float a,b,c,disc,p,q,x1,x2;
scanf("%f%f%f",&a,&b,&c); /* a,b,c */
disc=b*b-4*a*c; /* δ */
p=-b/(2*a);
q=sqrt(disc)/(2*a);
x1=p+q;
x2=p-q; /* 2 */
printf("x1=%f\nx2=%f\n",x1,x2); /* */
}
,1 3 2
x1=-1.000000
x2=-2.000000
abc
s=(a+b+c)/2
include <math.h>
main( )
{float a,b,c,s,area;
scanf("%f,%f,%f",&a,&b,&c)
s=1.0/2*(a+b+c);
area=sqrt(s*(s-a)*(s-b)*(s-c))
printf("a=%7.2f,b=%7.2f,c =%7.2f,s =%7.2f\n",a,b,c,s);
printf("area=%7.2f\n"area)
}
346
a= 3.00 b= 4.00 c= 6.00 s= 6.50
area= 5.33
printf()
scanf()
putchar()getchar()
1
#include <stdio>
main()
{
double x=213.82631;
printf(“%-6.2e\n”,x);
}
A 213.82 B 21.38E+01
C 2.14E+02 D -2.14E2
C
212345 678 x y
#include <stdio.h>
main()
{
int x;
float y;
scanf(“%3d%f,&x,&y);
}
A 12345 B 123
C 45 D 345
A 45.0000000
B 45678.000000
C 678.000000
D 123.000
B
A
3
#include <stdio.h>
main()
{
float f=3.1415927;
printf(“%f,%5.4f,%3.3f”,f,f,f);
}
3.1415933.14163.142