c语言中三角形判断函数 C语言三角形判断

用C语言编写一个判断三角形的函数,求大佬帮忙修改!

#includestdio.h

雨花台ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!

#includemath.h

main()

{ float a,b,c;

float s,area;

scanf("%f,%f,%f",a,b,c);

if(a+bcb+caa+cb)

{ s=(a+b+c)/2;

area=sqrt(s*(s-a)*(s-b)*(s-c)); //有改动 

printf("the area is:%f\n",area);

if(a==ba==c)

printf("equilateral triangle\n");

else if(a==b||b==c||a==c)

printf("isoceles triangle\n");

else if(fabs(a*a+b*b-c*c)1e-8||fabs(a*a+c*c-b*b)1e-8||fabs(b*b+c*c-a*a)1e-8) //有改动

printf("right angled triangle\n");

else

printf("triangle");

}

else

printf("can not compose triangle");

}

c语言判断三角形类型调用函数函数

void rectan(){

double a,b,c, square;

double tmp;

char max;

scanf("%lf%lf%lf",a,b,c);

if( a == b || b==c || a ==c){//等腰三角形一定为锐角(包含等边)

printf("锐角三角形\n");

return;

}

//将角C选为最大角,若输入不是此交换使C最大

max = ab?(tmp = a,'a'):(tmp = b,'b');

max = tmpc?max:(tmp = c,'c');

if(max != 'c'){

tmp = a;

a = c;

c = tmp;

}

c语言判断三角形形状

你对r赋值的时候用了两个等于号“==”,赋值用一个等于号,判断 的时候采用两个!

而且输出语句应该放在第一个if外面,应该就这两个问题,代码如下:

#include stdio.h

int main(){

int a, b, c, r;

printf("Please input three integers:\n");

scanf("%d%d%d",a,b,c);

if(a == b ==c) r = 3;

else{

if(a + b c a - b c){

if(b + c a b - c a){

if(a + c b a - c b){

if(a * a == b * b + c * c || b * b == a * a +c * c || c * c == a * a + b * b)

r = 1;

else if((a == b a != c) || (b == c a != b )|| (a ==c b != a))

r = 2;

else

r = 0;

}

else

r = -1;

}

else

r = -1;

}

else

r =-1;

}

if(r == -1)

printf("Tt's not an integer.");

else if(r == 0)

printf("It's an scalenous triangle.");

else if(r == 1)

printf("It's an right-angeld triangle.");

else if(r == 2)

printf("It's an isosceles triangle.");

else if(r == 3)

printf("It's an equilateral triangle.");

return 0;

}

当前标题:c语言中三角形判断函数 C语言三角形判断
文章位置:https://www.cdcxhl.com/article34/hisope.html

成都网站建设公司_创新互联,为您提供品牌网站建设移动网站建设网页设计公司微信公众号商城网站

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

外贸网站建设