#include <stdio.h>
#include <stdlib.h>
/**
*不适用乘法运算符实现2*16
*2^n=16 n=4
*/
main() {
printf("%d",2<<4);
getch();
}
结论
左移一位相当于*2
右移一位相当于/2
原理:0010 左移一位为0100=4
#include <stdio.h>
#include <stdlib.h>
/**
*不适用乘法运算符实现2*16
*2^n=16 n=4
*/
main() {
printf("%d",2<<4);
getch();
}
结论
左移一位相当于*2
右移一位相当于/2
原理:0010 左移一位为0100=4