MT4智能交易编程教程-算术运算 算术运算符包括加法和乘法运算: - Sum of variables i = j + 2;
- Difference of variables i = j - 3;
- Changing the sign x = - x;
- Product of variables z = 3 * x;
- Division quotient i = j / 5;
- Divisions reminder minutes = time % 60;
- Adding 1 to the variable value i++;
- Adding 1 to the variable value ++i;
- Subtracting 1 from the variable value k--;
- Subtracting 1 from the variable value --k;
复制代码加减运算只用于变量中,不能用于常量里。加减前缀 (++i) 和 (-k)只在变量用在表达式前才用于这个变量。加减后缀 (i++)和(k-)只在变量用在表达式后才用于这个变量。Important Notice - int i=5;
- int k = i++ + ++i;
复制代码示例: - int a=3;
- a++; // 有效表达式
- int b=(a++)*3; // 无效表达式
-
复制代码
|