我如何...用&&amp ;;制作if条件操作者 [英] How do i...make a if condition with && operator

查看:80
本文介绍了我如何...用&&amp ;;制作if条件操作者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果条件与&& c ++运算符



我尝试过:



if else condition与&&我不能这样做

how to do if condition with && operator in c++

What I have tried:

if else condition with && i cant do it

推荐答案

c ++是带对象扩展的C,所以学习C语言基础知识是个好主意。

C编程语言 - 维基百科,免费的百科全书 [ ^ ]

https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf [ ^ ]

http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf [ ^ ]
c++ is C with object extension, so it is a good idea to learn C language basics.
The C Programming Language - Wikipedia, the free encyclopedia[^]
https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[^]
http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[^]


尝试:

Try:
if (a >= b && a <= c)
   {
   DoSomething(1);
   }
else
   {
   DoSomething(2);
   }


&& 运算符不能替换 else 子句。相反,它等同于嵌套的 if 语句,例如

The && operator cannot replace the else clause. Instead, it is equivalent to nested if statements, e.g.
if (a > b && a > c)
{
  // do something
}



相当于


is equivalent to

if (a > b)
{
  if (a > c)
  {
    // do something
  }
}


这篇关于我如何...用&amp;&amp ;;制作if条件操作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆