Advertisement
nicuvlad76

Untitled

Dec 18th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. ///operatii pe biti
  4. int main()
  5. {
  6. int n;
  7. ///operatorul de negatie
  8. cout<<(~0)<<"\n";///-1
  9. cout<<(~5)<<"\n";///-6
  10. cout<<(~(-5))<<"\n";///4
  11. ///operatorul &
  12. cout<<"operatorul &\n ";
  13. cout<<(5 & 7)<<"\n";
  14. /* cin>>n;
  15. cout<<(n &(n-1))<<"\n";///n este putere a lui 2 daca expre sia este 0
  16.  
  17. */
  18. cout<<" operatorul | \n";
  19. cout<<(8|5)<<'\n';
  20.  
  21. cout<<"operatorul ^ \n";
  22. cout<<(12^5)<<"\n";
  23. cout<<(12^5^5)<<"\n";
  24. cout<<(12^12)<<"\n";
  25. ///interschimbare tipul intreg
  26. int a , b;
  27. a=2 ,b=7;
  28. a^=b^=a^=b;
  29. cout<<a<<' '<<b ;
  30. cout<<'\n';
  31. char x='a',y='c';
  32. x^=y^=x^=y;
  33. cout<<x<<' '<<y;
  34.  
  35. cout<<"\noperator de deplasare la stanga(<<)\n";
  36.  
  37. cout<<(1<<5)<<" "<<(13<<3);
  38.  
  39. cout<<"\noperatorul de deplasare la dreapta (>>)\n";
  40.  
  41. cout<<(13>>2);
  42. return 0;
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement