zoukankan      html  css  js  c++  java
  • 30天代码day2 Operators

    Operators
    These allow you to perform certain operations on your data. There are 3 basic types:

    1. Unary: operates on 1 operand
    2. Binary: operates on 2 operands
    3. Ternary: operates on 3 operands

    Arithmetic Operators
    The binary operators used for arithmetic are as follows:

    • +: Additive
    • -: Subtraction
    • *: Multiplication
    • /: Division
    • %: Remainder (modulo)

    Additional Operators

      • +: A binary operator used for String concatenation
      • ++: This unary operator is used to preincrement 前自增(increment by 1 before use) when prepended to a variable name or postincrement 后自增(increment by 1 after use) when appended to a variable.
      • --: This unary operator is used to predecrement 前自减(decrement by 1 before use) when prepended to a variable name or postdecrement 后自减(decrement by 1 after use) when appended to a variable.
      • !: This unary operator means not (negation). It's used before a variable or logical expression that evaluates to true or false.
      • ==: This binary operator is used to check the equality of 2 primitives.
      • !=: This binary operator is used to check the inequality of 2 primitives.
      • <, >, <=, >=: These are the respective binary operators for less than, greater than, less than or equal to, and greater than or equal to, and are used to compare two operands.
      • &&, ||: These are the respective binary operators used to perform logical AND and logical OR operations on two boolean (i.e.: true or false) statements.
      • ? : This ternary operator is used for simple conditional statements (i.e.: if ? then : else).
  • 相关阅读:
    luogu P2639 [USACO09OCT]Bessie的体重问题Bessie's We…
    1001. 害死人不偿命的(3n+1)猜想 (15)
    1003. 我要通过!(20)
    1002. 写出这个数 (20)
    《C语言程序设计(第四版)》阅读心得(一)
    1006. 换个格式输出整数 (15)
    背包问题之多重背包
    背包问题之完全背包
    背包问题之0-1背包
    动态规划例题
  • 原文地址:https://www.cnblogs.com/helloworld7/p/10454449.html
Copyright © 2011-2022 走看看