Advertisement
VoronVU

Использование побитового оператора

Nov 11th, 2015
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.    cout << "Enter a number: ";
  6.    int Input = 0;
  7.    cin >> Input;
  8.  
  9.    int Half = Input >> 1;
  10.    int Quarter = Input >> 2;
  11.    int Double = Input << 1;
  12.    int Quadruple = Input << 2;
  13.  
  14.    cout << "Quarter: " << Quarter << endl;
  15.    cout << "Half: " << Half << endl;
  16.    cout << "Double: " << Double << endl;
  17.    cout << "Quadruple: " << Quadruple << endl;
  18.  
  19.    return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement