In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "introduction of C++ expressions and common sentences". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought. Let's study and learn the introduction of C++ expressions and common sentences.
C++ expressions and sentences
Logical operator and relational operator
Logical operator, by its name, we can tell that it is used to do logical operation, the result of logical operation expression is often the value of Boolean type. We often talk about logic and (& or) and logic or (| or |) are logical operators. We can see that there are two kinds of parentheses, one is single symbol, the other is double symbol, in fact, they are often equivalent. It is generally used to use the'&'or'|'of a single symbol for the logic operation of a single variable, while expressions often use double symbols'& &'or'| |'. In addition to these two, in fact, there is a logic operator, logic is not'!', the effect is to reverse a variable. These are the basics of the C language should be known.
Relational operators, similarly, it is easy to know that they are used to represent the relationship between variables, which we often see, greater than, less than, greater than or equal to, less than or equal to, equal to, not equal to, and so on.
Self-addition and self-subtraction
Self-addition is "+ +" and self-subtraction is "- -", which is often used to increase or subtract 1 from the left value. There is only one thing worth mentioning about these two operators, that is, "+ + I" or "--I" is often used in C++ 's for loop instead of "I color +" or "I color -" because the former is more efficient. For C++, high efficiency is a priority, even if the efficiency is already very high, but the pursuit of efficiency is endless!
Conditional operator
The conditional operator is a ternary operator, that is, there are three operands involved in the operation, and the final result is a conditional judgment. As follows:
A > b? C: d
The above expression is equivalent to
If (a > b) {
Return c
}
Else {
Return d
}
Bit operator
The so-called bit operator essentially converts a number into a binary number, and then operates on each bit. The commonly used bit operators are:
~ reverse by bit
Move left, move right
& bitwise vs.
^ XOR by bit
| | Bitwise or
Sentences in C++
There are also many kinds of sentences in C++, such as conditional statements, loop statements, simple statements and so on. The simplest sentence is actually a ";"
(1) conditional statement
A conditional statement is a statement that judges a known condition and then decides whether to execute its contents.
If (I > 0)
{
Centrd
}
(2) Loop statement
The statement used for loop execution.
For (int item0; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.