Advertisement
Guest User

Untitled

a guest
May 27th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int find_num_bit(int num){
  4. int i=0;
  5. while(num>0){
  6. i++;
  7. num=num>>1;
  8. }
  9. return i;
  10. }
  11.  
  12. int main(){
  13. int num;
  14. int b_num;
  15. int i;
  16. for (num=1;num<=100;num++){
  17. printf("%d&3= %d -> ",num,num&3);
  18. int n=num&3;
  19. for (int c = 3; c >= 0; c--)
  20. {
  21. int k = n >> c;
  22.  
  23. if (k & 1)
  24. printf("1");
  25. else
  26. printf("0");
  27. }
  28. printf(" metto nello scan scan degli: ");
  29. switch (n){
  30. case 0: cout<<"00"; break;
  31. case 1: cout<<"01"; break;
  32. case 2: cout<<"10"; break;
  33. case 3: cout<<"11"; break;
  34.  
  35. }
  36. cout<<endl;
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement