填空题
下列给定程序中,函数fun的功能是:根据输入的三个边长(整型值),判断能否构成三角形。若能构成等边三角形,则返回3;若是等腰三角形,则返回2;若能构成三角形,则返回1;若不能,则返回0。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#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 2;
else if(a==b||b==c||a==c)
return 2;
/**********found**********/
else return 3;
}
else return 0;
}
void main()
{
int a, b, c, shape;
printf("/nlnput a, b, c:");
scanf("%d%d%d", &a, &b, &c);
printf("/na=%d, b=%d, c=%d/n", a, b, c);
shape=fun(a, b, c);
printf("/n/nThe shape:%d/n", shape);
}