#include <cstdio> #include <iostream> using namespace std; int main() { int i=3; int a=i<<1; //3*2^1 int b=i<<2; //3*2^2 int c=1<<i; //1*2^3 int d=2<<i; //2*2^3 //a<<b == a*2^b; cout<<a<<endl<<b<<endl<<c<<endl<<d<<endl; return 0; }
#include <cstdio> #include <iostream> using namespace std; int main() { int i=3; int a=i<<1; //3*2^1 int b=i<<2; //3*2^2 int c=1<<i; //1*2^3 int d=2<<i; //2*2^3 //a<<b == a*2^b; cout<<a<<endl<<b<<endl<<c<<endl<<d<<endl; return 0; }