下列给定程序中 函数fun()的功能是:根据输入的3个边长(整型值) 判断能否构成三角形:若能构成等边

计算机 角形,边长,程序 已帮助 人

下列给定程序中,函数fun()的功能是:根据输入的3个边长(整型值),判断能否构成三角形:若能构成等边三角形,则返回3,若是等腰三角形,则返回2,若能构成三角形则返回1,若不能,则返回0。

请改正程序中的错误,使它能得出正确的结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。

试题程序:

include <math. h>

int fun(int a, int b, int c)

{ if (a+b>c&&b+c>a&&a+c>b)

{ if (a==b&&b==c)

/*************found**************/

return 1;

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

return 2;

/*************found**************/

else return 3;

}

else return 0;

}

main ()

{ int a,b, c, shape;

printf(" Input a,b,c: ");

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

printf (" a=%d, b=%d, c=%d ",a,b,c);

shape=fun (a,b, c);

printf (" The shape : %d ", shape);

}

请帮忙给出正确答案和分析,谢谢!

热搜:下面程序的功能是输出数组s中最大元素