8 条题解

  • 2
    @ 2024-7-24 13:57:44
    #include<bits/stdc++.h>
    using namespace std;
    stack<int>s;
    int main(){
    	int n;
    	cin>>n;
    	while(n!=0){
    		s.push(n%2);
    		n/=2;
    	}
    	while(!s.empty()){
    		cout<<s.top();
    		s.pop();
    	}
    	return 0;
    } 
    
    • 1
      @ 2024-7-24 13:57:20

      #include<bits/stdc++.h> using namespace std; stack s; int main(){ int n; cin>>n; while(n!=0){ s.push(n%2); n/=2; } while(s.size()!=0){ cout<<s.top(); s.pop(); } return 0; }

      • 1
        @ 2024-7-24 13:39:28
        #include<iostream>
        using namespace std;
        int main(){
        	int n;
        	cin >> n;
        	int r[100];
        	int i, j=0;
            //对十进制数进行除以二取余并以此存放到列表中
        	for ( i = 0;n > 0; i++){
        		r[i] = n % 2;
        		n = n / 2;
        		j++;
        	}
            //依次取出从列表的最后一位到第一位余数
        	for (j=j-1;j >= 0; j--){
        		cout << r[j];
        	}
        	return 0;
        }
        
        • 0
          @ 2024-7-24 13:58:04

          #include using namespace std; int main(){ int n; cin >> n; int r[100]; int i, j=0

          for ( i = 0;n > 0; i++){
          	r[i] = n % 2;
          	n = n / 2;
          	j++;
          }
          for (j=j-1;j >= 0; j--){
          	cout << r[j];
          }
          return 0;
          

          }

          • 0
            @ 2024-7-24 13:57:43

            #include<bits/stdc++.h> using namespace std; stacka; int main(){ int z,s,x,d; cin>>z; while(z!=0){ a.push(z%2); z=z/2; } while(!a.empty()){ cout<<a.top(); a.pop(); } return 0; }

            • 0
              @ 2024-7-24 13:57:42

              #include using namespace std; int main(){ int n; cin >> n; int r[100]; int i, j=0;

              for ( i = 0;n > 0; i++){
              	r[i] = n % 2;
              	n = n / 2;
              	j++;
              }
              for (j=j-1;j >= 0; j--){
              	cout << r[j];
              }
              return 0;
              

              }

              • 0
                @ 2024-7-24 13:57:11

                #include<bits/stdc++.h> using namespace std; stacka; int main(){ int z,s,x,d; cin>>z; while(z!=0){ a.push(z%2); z=z/2; } while(!a.empty()){ cout<<a.top(); a.pop(); } return 0; }

                • 0
                  @ 2024-7-24 13:54:28
                  #include<bits/stdc++.h>
                  using namespace std;
                  stack<int>s;
                  int main(){
                  	int n;
                  	cin>>n;
                  	while(n!=0){
                  		s.push(n%2);
                  		n/=2;
                  	}
                  	while(!s.empty()){
                  		cout<<s.top();
                  		s.pop();
                  	}
                  	return 0;
                  }
                  

                  栈做法

                  • 1

                  信息

                  ID
                  2293
                  时间
                  1000ms
                  内存
                  256MiB
                  难度
                  1
                  标签
                  (无)
                  递交数
                  156
                  已通过
                  104
                  上传者