Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int find_num_bit(int num){
- int i=0;
- while(num>0){
- i++;
- num=num>>1;
- }
- return i;
- }
- int main(){
- int num;
- int b_num;
- int i;
- for (num=1;num<=100;num++){
- printf("%d&3= %d -> ",num,num&3);
- int n=num&3;
- for (int c = 3; c >= 0; c--)
- {
- int k = n >> c;
- if (k & 1)
- printf("1");
- else
- printf("0");
- }
- printf(" metto nello scan scan degli: ");
- switch (n){
- case 0: cout<<"00"; break;
- case 1: cout<<"01"; break;
- case 2: cout<<"10"; break;
- case 3: cout<<"11"; break;
- }
- cout<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement