第三章
程序员文章站
2022-05-07 08:01:48
...
例3.1
int main()
{
float f,c;
f=64.0;
c=(5.0/9)*(f-32);
printf("f=%f\nc=%f\n",f,c);
return 0;
}
例3.2
int main()
{
float p0=1000,r1=0.0036,r2=0.0225,r3=0.0198,p1,p2,p3;
p1=p0*(1+r1);
p2=p0*(1+r2);
p3=p3*(1+r3);
printf("p1=%f\np2=%f\n",p1,p2,p3);
return 0;
}
例3.3
int main()
{
char c1,c2;
c1='A';
c2=c1+32;
printf("%c\n",c2);
printf("%d\n",c2);
return 0;
}
例3.4
#include<math.h>
int main()
{
double a,b,c,s,area;
a=3.67;
b=5.43;
c=6.21;
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("a=%f\tb=%f\t%f\n",a,b,c);
printf("area=%f\n",area);
return 0;
}
例3.5
#include<math.h>
int main()
{double a,b,c,disc,x1,x2,p,q;
scanf("%if%if%if",&a,&b,&c);
disc=b*b-4*a*c;
p=-b/(2.0*a);
q=sqrt(disc)/(2.0*a);
x1=p+q;x2=p-q;
printf("x1=%7.2f\nx2=%7.2f\n",x1,x2);
return 0;
}
例3.6
int main()
{double a=1.0;
printf("%f\n",a/3);
return 0;
}
例3.7
int main()
{
float a;
a=10000/3.0;
printf("%f\n",a);
return 0;
}
例3.8
int main()
{
char a='B',b='O',c='Y';
putchar(a);
putchar(b);
putchar(c);
putchar('\n');
return 0;
}
例3.9
int main()
{
char a,b,c;
a=getchar();
b=getchar();
c=getchar();
putchar(a);
putchar(b);
putchar(c);
putchar('\n');
return 0;
}
例3.10
int main()
{ char c1,c2;
c1=getchar();
c2=c1+32;
putchar(c2);
putchar('\n');
return 0;
}