zoukankan      html  css  js  c++  java
  • 数据运算

    算数运算:

    image

    比较运算:

    image

    赋值运算:

    image

    逻辑运算:

    image

    成员运算:

    image

    身份运算:

    image

    位运算:

    image

    #!/usr/bin/python
      
    a = 60            # 60 = 0011 1100
    b = 13            # 13 = 0000 1101
    c = 0
      
    c = a & b;        # 12 = 0000 1100
    print "Line 1 - Value of c is ", c
      
    c = a | b;        # 61 = 0011 1101
    print "Line 2 - Value of c is ", c
      
    c = a ^ b;        # 49 = 0011 0001 #相同为0,不同为1
    print "Line 3 - Value of c is ", c
      
    c = ~a;           # -61 = 1100 0011
    print "Line 4 - Value of c is ", c
      
    c = a << 2;       # 240 = 1111 0000
    print "Line 5 - Value of c is ", c
      
    c = a >> 2;       # 15 = 0000 1111
    print "Line 6 - Value of c is ", c

    *按位取反运算规则(按位取反再加1)  

    详解http://blog.csdn.net/wenxinwukui234/article/details/42119265

    运算符优先级:

    image

    三元运算:

    result = 值1 if 条件 else 值2

    如果条件为真:result = 值1

    如果条件为假:result = 值2

    进制:

    二进制,01

    八进制,01234567

    十进制,0123456789

    十六进制,0123456789ABCDEF 二进制到16进制转换

    http://jingyan.baidu.com/album/47a29f24292608c0142399cb.html?picindex=1

  • 相关阅读:
    noip2018练习总结
    东方CannonBall (概率DP)
    数论
    逆序对
    USACO5.3 校园网Network of Schools(Tarjan缩点)
    USACO09FEB 改造路Revamping Trails(分层图模板)
    Comet OJ模拟赛 Day1
    Tarjan模板
    NOIP 天天爱跑步(树上差分)
    树上差分
  • 原文地址:https://www.cnblogs.com/sleeping-cat/p/9224362.html
Copyright © 2011-2022 走看看