【VB.NET】XOR 觀念

摘要:【VB.NET】XOR 觀念

在程式上

 Dim a As Integer = 10 ' 1010 in binary
        Dim b As Integer = 8  ' 1000 in binary
        Dim c As Integer = 6  ' 0110 in binary
        Dim firstPattern, secondPattern, thirdPattern As Integer
        firstPattern = (a Xor b)  '  2, 0010 in binary
        secondPattern = (a Xor c) ' 12, 1100 in binary
        thirdPattern = (b Xor c)  ' 14, 1110 in binary

        Console.WriteLine(firstPattern & "," & secondPattern & "," & thirdPattern)
        Console.Read()

顯示 : 2 12 14

 

 

 

 

既然走了! 就勇往的去 ......