怎么用c语言编程?
1个回答
展开全部
以“输入三个数,判断是否构成三角形”为例,
你可以试试
#include <stdio.h>
#include <math.h>
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 ") ;
}
你可以试试
#include <stdio.h>
#include <math.h>
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 ") ;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询