C 程序接收三个整数,看看它们是否构成三角形和直角

  • 本文关键字:是否 三角形 程序 整数 三个 c
  • 更新时间 :
  • 英文 :


我接到一个作业的问题,要求我制作一个程序,用户输入 3 个整数,然后检查它们是否可以是三角形的边。我应该为此使用嵌套的if语句,我不能在语句中使用&&,他们给我的公式是

num1 < num2 + num3 AND num1 < num2 - num3 

我对此感到非常困惑,任何帮助将不胜感激!

问题似乎是在问如何使用嵌套的ifAND 语句而不是&&运算符来实现逻辑 AND。

if (X && Y) foo;相当于if (X) if (Y) foo;

if (num1 < num2 + num3)       /* if this is true you enter the first scope */
{
if (num1 < num2 - num3)   /* if this is also true enter the second scope */
{
printf("TRUEn");
}
}
int a=1, b=2, c=3;
if (a<b+c)
{
if (a<b-c)
printf("Yes");
}

相关内容

最新更新