zoukankan      html  css  js  c++  java
  • C#中的运算(移位、异或、与、或)

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;

    namespace ConsoleApplication3
    {
        class Program
        {

            static void Main(string[] args)
            {
                ///<summary>
                /// 移位运算           
                ///</summary>
                int i = 7;
                int j = 2;
                Console.WriteLine(i >> j);   //输出结果为1

                ///<summary>
                /// 异或运算
                ///</summary>
                int x = 5;
                int y = 3;
                y ^= x;   //等价与y=y^x
                Console.WriteLine(y);        ////输出结果为6

                ///<summary>
                /// 或运算           
                ///</summary>
                int i = 7;
                int j = 2;
                Console.WriteLine(i | j);   //输出结果为7

                ///<summary>
                /// 与运算           
                ///</summary>
                int i = 7;
                int j = 2;
                Console.WriteLine(i & j);   //输出结果为2
            }
        }
    }

  • 相关阅读:
    Java String 乱码
    HBase非原理性浅析
    git cherry-pick
    数据结构之队列
    数据结构之栈
    算法之简单排序
    数据结构之数组
    数据结构简介
    Java类型信息
    基数排序
  • 原文地址:https://www.cnblogs.com/tianguook/p/1717485.html
Copyright © 2011-2022 走看看