為什么呢...
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? int x=1;
? ? ? ? ? ? bool a = ++x * x > 3;
? ? ? ? ? ? bool b = x > 2;//請賦值
? ? ? ? ? ? Console.WriteLine(a==b);
? ? ? ? }
? ? }
}
題目要求最后結果為True
2016-11-18
優(yōu)先級的問題,先自家所以x值變成2,再相乘,然后判斷,最后賦值給a.
bool a = ++x * x > 3; 相當于 x = x+1; a = x*x>3;?
2018-08-03
bool a = ++*x>3;//++x,值確實為2 第二個x的值是1好吧 2*1還是 2? 2>3 值為false
2016-11-18
?int x = 1; ?//x=1
bool a = ++x * x > 3; ?//1、++x,值為2。 ? ?2、2*2,值為4。 ? ?3、4>3,值為true
?bool b = x > 2; ?//1、x值為2。 ? 2、2>2,值為false
Console.WriteLine(a == b); ?//true ==false值為false
把Console.WriteLine(a == b); 改為Console.WriteLine(a != b); 后結果就為True。