• c++ 里面 << 左移 >> 右移的作用


    先上代码吧,看了之后你就会懂

    #pragma GCC optimize(1)
    #pragma GCC optimize(2)
    #pragma GCC optimize(3)
    #pragma GCC optimize("Ofast")
    #include<bits/stdc++.h>
    #define rep(i,j,k) for(register int i=(j);i<=(k);++i)
    using namespace std;
    template<class T> inline void read(T &x) {
        x=0;
        register char c=getchar();
        register bool f=0;
        while(!isdigit(c))f^=c=='-',c=getchar();
        while(isdigit(c))x=x*10+c-'0',c=getchar();
        if(f)x=-x;
    }
    int main() {
        int num = 32;
        
        int half = num >> 1;
        int quarter = num >> 2;
        int doublenum = num << 1;
        int quadruple = num << 2;
        
        printf("half = %d
     quarter = %d
     doublenum = %d
     quadruple = %d
    ", half, quarter, doublenum, quadruple);
        
        return 0;
    }

    half = 16

    quarter = 8

    doublenum = 64

    quadruple = 128

    注意:

    不能出现cout<< 2>>1 <<endl; 必须得打上括号 cout<< (2>>1) <<endl; 因为>>和<<运算级是一样的,并且这里是输入输出运算符,编译器会无法识别。

  • 相关阅读:
    flask之Blueprint蓝图
    flask之Flask、config配置
    flask之路由route
    flask之request
    flask之response
    pyhton中的深浅copy
    jQuery选择器
    Html常用标签
    python中的字典dict
    python基础知识
  • 原文地址:https://www.cnblogs.com/LJA001162/p/12675536.html
Copyright © 2020-2023  润新知