1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include <iostream> #include <cstdio> #include <cstring> #include <string> using namespace std; int main() { int n,res; int positionInByte,byteNo; while(scanf("%d",&n)!=EOF) { res=0; for(int i=0;i<32;i++) { if((1<<i)&n) { byteNo=i/8; positionInByte=i%8; res |= (1<<((3-byteNo)*8+positionInByte)); } } printf("%d converts to %d\n",n,res); } return 0; } |