您好,欢迎来到锐游网。
搜索
您的当前位置:首页位运算

位运算

来源:锐游网
位运算

#include #include using namespace std; int abs1(int x) {

int y; y=x>>31;

return (x+y)^y; }

void print(int x) { int p[32]; int top=0,i; if(x<0) { cout<<\"-\"; x=abs1(x); } while(x!=0) { p[top++]=x%2; x/=2; } for(i=top; i>=1; i--) cout<int sign(int x) { return x>>31|(unsigned(-x))>>31; }

unsigned B2G(unsigned B ) {

return B ^ (B>>1) ; }

unsigned G2B(unsigned G) { unsigned B; B=G^(G>>1);

B=G^(G>>2); B=G^(G>>4); B=G^(G>>8); B=G^(G>>16); return B; }

int avg(int x, int y) { return (x&y)+((x^y)>>1); }

void Swap(int &x, int &y) { x=x^y; y=y^x; x=x^y; }

bool pow2(int x) { return ((x&(x-1))==0&&(x!=0)); }

int findchess(int x, int y, int k) { int re=0; int i; for(i=y; i<=x; i++) { re+=((k>>(i-1))&1); } return re; }

int findc(int x) { int i; int re=0; for(i=31; i>=0; i--) { re+=(x>>i&1); } return re; }

int main() {

int x,y;

while(cin>>x>>y) { cout<<(x>>3)<>x>>y; print(x); print(y); x=(x^(x+1))>>1; print(x); }

return 0; }

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- ryyc.cn 版权所有 湘ICP备2023022495号-3

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务