怎么用c语言编程?

2024-11-13 08:05:49
推荐回答(1个)
回答1:

以“输入三个数,判断是否构成三角形”为例,
你可以试试
#include
#include
void main()
{
float a,b,c,d,s;
scanf("%f,%f,%f",&a,&b,&c);
if(a+b>c&&a+c>b&&b+c>a)
{
if(a==b||b==c||c==a)
{if(a==b&&b==c) printf("this is a dengbiansanjiaoxing\n");
else printf("this is a dengyao sanjiaoxing\n");
}
else if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a)
printf("this is zhijiao\n");
else printf("yibansanjiaoxing\n");
d=(a+b+c)/2;
s=sqrt(d*(d-a)*(d-b)*(d-c));
printf("%f\n",s);
}
}
else printf("bushi sanjiaoxing ") ;
}