我如何在 C 中调用以下函数?
How do i call the below function in C?
Returning true
or false
bool valid_triangle(float x, float y, float z);
int main(void)
{
float a = get_float("Enter the 1st Value : \n");
float b = get_float("Enter the 2nd Value : \n");
float c = get_float("Enter the 3rd Value : \n");
return valid_triangle(a,b,c);
}
bool valid_triangle(float x, float y, float z)
{
if(x <= 0 || y <= 0 || z <= 0 )
{
return false;
}
if((x + y <= z) || (x + z <= y) || (z + y <= x))
{
return false;
}
return true;
}
变化:
return valid_triangle(a,b,c);
至:
bool result = valid_triangle(a,b,c);
printf("%d\n", result);
说明:C11 标准提到了 main
函数的这两个有效签名:
int main(void);
int main(int argc, char* argv[]);
None 其中 return bool
.
Returning
true
orfalse
bool valid_triangle(float x, float y, float z);
int main(void)
{
float a = get_float("Enter the 1st Value : \n");
float b = get_float("Enter the 2nd Value : \n");
float c = get_float("Enter the 3rd Value : \n");
return valid_triangle(a,b,c);
}
bool valid_triangle(float x, float y, float z)
{
if(x <= 0 || y <= 0 || z <= 0 )
{
return false;
}
if((x + y <= z) || (x + z <= y) || (z + y <= x))
{
return false;
}
return true;
}
变化:
return valid_triangle(a,b,c);
至:
bool result = valid_triangle(a,b,c);
printf("%d\n", result);
说明:C11 标准提到了 main
函数的这两个有效签名:
int main(void);
int main(int argc, char* argv[]);
None 其中 return bool
.