Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么连999都出问题呢?请高人指点#include <iostream> using namespace std; int i,n,sum,a[100000]; int boot(int ); void main() { while (1) { cin>>n; if(n==0) break; else if(n>=10) { sum=boot(n); cout<<sum<<endl; } else cout<<n<<endl; } } int boot(int n) { for(i=0;n>0;i++) { a[i]=n%10; n=n/10; } for(i=0;a[i]>0;i++) { n+=a[i]; } if(n>=10) n=boot(n); return n; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator