目录
一、BC26 计算三角形的周长和面积
#include <stdio.h>
#include <math.h>
int main()
{
float a=0;
float b=0;
float c=0;
scanf("%f %f %f",&a,&b,&c);
float l=a+b+c;
float p=l/2;
float s=sqrt(p*(p-a)*(p-b)*(p-c));
printf("circumference=%.2f area=%.2f\n",l,s);
return 0;
}
二、BC25 计算体重指数
int main()
{
//体质指数(BMI)=体重(kg)÷身高^2(m)
float weight = 0;
float height = 0;
scanf("%f %f", &weight, &height);
height = height / 100.0;//输入cm换算为m
float BMI = weight / (height*height);
printf("%.2f\n", BMI);
return 0;
}
三、BC19 反向输出一个四位数
#include <stdio.h>
int main()
{
int x = 0;
scanf("%d", &x);
while (x)
{
printf("%d",x % 10);
x = x / 10;
}
return 0;
}
四、BC21 浮点数的个位数字
#include <stdio.h>
int main()
{
float a=0;
scanf("%f",&a);
int x=(int)a%10;
printf("%d",x);
return 0;
}