#include <stdio.h>
int main()
{
int x,y,z;
printf ("Side x: ");
scanf ("%d",&x);
printf ("Side y: ");
scanf ("%d",&y);
printf ("Side z: ");
scanf ("%d",&z);
if (x+y>z&&x+z>y&&z+y>x)
printf ("\nTriangle can be performed");
else
printf ("\nTriangle cannot be performed");
return 0;
}
答案 0 :(得分:0)
您可以使用嵌套的if
语句。
triangle = false;
if (x + y > z) {
if (x + z > y) {
if (z + y > x) {
triangle = true;
}
}
}
if (triangle) {
printf("\nTriangle can be performed");
} else {
printf("\n Triangle cannot be performed");
}