大神求教:循环移位程序的分析
程序代码:
#include<stdio.h> int right(unsigned value,int n); int left(unsigned value,int n); int right(unsigned value,int n){ unsigned z; z=(value>>n)|(value<<(16-n)); return z; } int left(unsigned value,int n){ unsigned z; z=(value>>(16-n))|(value<<n); return z; } int main(){ unsigned a; int n; printf("input:\n"); scanf("%o",&a); printf("input:\n"); scanf("%d",&n); if(n>0){ right(a,n); printf("the result is:%o\n",right(a,n)); } else{ n=-n; left(a,n); printf("the result is :%o\n",left(a,n)); } return 0; }
以其中向右移动的函数为例。
z=(value>>n)|(value<<(16-n));
这句话给解释一下吧。举例子说明一下就行