#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; while(n){ cout<<n%10<<" "; n=n/10; } return 0; }
#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; }
while(n!=0) 没必要,直接while(n)即可
#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; }
#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
注册一个 睿爸信奥 通用账户,您就可以在我们提供的所有在线评测服务上提交代码、参与讨论。
使用您的 睿爸信奥 通用账户