5 solutions

  • 2
    @ 2024-11-3 9:29:56
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int x;
        cin>>x;
        if(x<0)
        {
            x=-x;
            cout<<1;
        }
        else
        {
            cout<<0;
        }
        for(int i=30;i>=0;i--)
        {
            if(x>>i&1)
            {
                cout<<1;
            }
            else
            {
                cout<<0;
            }
        }
        return 0;
    }
    
    • 1
      @ 2026-7-7 14:48:55
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	int x;
      	cin>>x;
      	if(x<0)
      	{
      		x=-x;
      		cout<<1;
      	}
      	else
      	{
      		cout<<0;
      	}
      	bitset<32> a(x);
      	for(int i=30;i>=0;i--)
      	{
      		cout<<a[i];
      	}
      	return 0;
      }
      
      
      
      • 0
        @ 2026-10-17 10:47:21
        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
            int n,c;
            cin>>n;
            c=n;
            n=abs(n);
            bitset<32> a(n);
            if(c<0){
                a[31]=1;
            }
            cout<<a;
            return 0;
        }
        
        • 0
          @ 2026-6-20 9:37:45
          #include <bits/stdc++.h>
          using namespace std;
          
          int main()
          {
          	int x;
          	cin>>x;
          	if(x<0)
          	{
          		x=-x;
          		cout<<1;
          	}
          	else
          	{
          		cout<<0;
          	}
          	for(int i=30;i>=0;i--)
          	{
          		if(x>>i&1)
          		{
          			cout<<1;
          		}
          		else
          		{
          			cout<<0;
          		}
          	}
          	return 0;
          }
          • 0
            @ 2026-1-3 10:13:00
            #include<bits/stdc++.h>
            using namespace std;
            int main()
            {
            	int x;
            	cin>>x;
            	if(x<0)
            	{
            		x=-x;
            		cout<<1;
            	}
            	else
            	{
            		cout<<0;
            	}
            	bitset<32> a(x);
            	for(int i=30;i>=0;i--)
            	{
            		cout<<a[i];
            	}
            	return 0;
            }
            
            
            • 1

            Information

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