一个很一般的程序
#include<iostream>
using namespace std;
void main(){
int a,b,p;
cout<<"entre a,b:"<<endl;
cin>>hex>>a>>b;
cout<<"a=";
cout.width(8); //宽度是8
cout.fill('0');//前面补0
cout <<hex << a<<endl;
cout<<"b=";
cout << hex << b<<endl;
p=b&0X80000000;
//cout << hex << p<<endl;
//cout << dec << p<< endl;
//cout<<p<<endl;
cout<<"after left shift a b=";
if(p==0){
a=a<<1;
b=b<<1;
cout.width(8);
cout.fill('0');
cout<<a<<" ";
cout<<b<<endl;
}
else{
a=a<<1;
a=a|1;
b=b<<1;
cout.width(8);
cout.fill('0');
cout<<a<<" ";
cout<<b<<endl;
}
}