6 条题解

  • 2
    @ 2025-2-4 11:47:46
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	int n;
    	cin>>n;
    	while(n){
    		cout<<n%10<<" ";
    		n=n/10;
    	}
    	return 0;
    }
    
    • 2
      @ 2025-2-4 11:44:57
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
      	int n,s;
      	cin>>n;
      	for(;;)
      	{
      	 
      	 if(n/10>=1)
      	 {
      	    cout<<n%10<<" ";
      		n=n/10;
      	 }
      	 else
      	 	 break; 
      	}cout<<n%10;
      	return 0;
      }
      
      • 1
        @ 2025-4-13 11:48:04
        #include<bits/stdc++.h>
        using namespace std;
        int main(){
        	int n;
        	cin>>n;
        	while(n){
        		cout<<n%10<<" ";
        		n=n/10;
        	}
        	return 0;
        }
        
        
        • 1
          @ 2025-1-26 16:43:28

          while(n!=0) 没必要,直接while(n)即可

          • 1
            @ 2025-1-19 21:28:35

            #include<bits/stdc++.h> using namespace std; int main(){ int n=0; cin>>n; while(n!=0){ cout<<n%10<<" "; n=n/10; } return 0; }

            • 0
              @ 2025-4-6 12:13:15
              #include<bits/stdc++.h>
              using namespace std;
              int main(){
              int n;
              cin>>n;
              while(n){//n!=0时
              cout<<n%10<<" ";
              n=n/10;//去掉最后一位
              }
              return 0;
              }
              

              input:12567; output:7 6 5 2 1

              • 1

              信息

              ID
              79
              时间
              1000ms
              内存
              128MiB
              难度
              1
              标签
              (无)
              递交数
              48
              已通过
              38
              上传者