输出二进制

root 站长 2019-10-12 11:36:57 2
#include <iostream>

using namespace std;



int main()
{
    int n = 10;
    int x = -n;
    
    for (int i = 31; i >= 0; i-- ) cout << (n >> i & 1);
    cout << endl << endl;
    for (int i = 31; i >= 0; i-- ) cout << ((~n) >> i & 1);
    cout << endl << endl;
    for (int i = 31; i >= 0; i-- ) cout << ((~n +1) >>i & 1 );
    cout << endl << endl;

    return 0;
}
{{ vote && vote.total.up }}