2 solutions

  • 3
    @ 2024-7-9 10:23:39
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int a;
    	cin>>a;
    	for(int i=31;i>=0;i--)
    	{
    		if(a>>i&1)
    		{
    			cout<<1;
    		}
    		else cout<<0;
    	}
    	return 0;
    }
    
    
    • 0
      @ 2025-10-5 13:55:48
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	int n;
      	cin>>n;
      	bitset<32> a(n); //将n的补码存到a之中 
      	for(int i=31;i>=0;i--) //从高位遍历到低位 
      	{
      		cout<<a[i];
      	}
      	return 0;
      }
      
      
      • 1

      Information

      ID
      127
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      1
      Tags
      (None)
      # Submissions
      30
      Accepted
      19
      Uploaded By