Advertisement
qberik

Untitled

Oct 18th, 2021
947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #define BITS 8
  3. using namespace std;
  4. int main(){
  5.  
  6.   int M = 0;
  7.   int bits[BITS] = {};
  8.  
  9.   cout << "Введите M" << endl;
  10.   cin >> M;
  11.  
  12.   M += 1;
  13.  
  14.   for( int i = 0; i < BITS; i++ )
  15.     bits[BITS-i-1] = ( M & ( 1 << i ) ) != 0;
  16.  
  17.   cout << "биты M + 1" << endl;
  18.   for( int i = 0; i < BITS; i++ )
  19.     cout << bits[i];
  20.   cout <<endl;
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement