Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

why!高人半忙指点一下!

Posted by liuxiaoyu at 2011-04-28 19:31:34 on Problem 1519
我的代码为什么老ac不了?愤啊!!!
#include <iostream>
using namespace std;
int root (int n)
{   int a;
   do
   {   a=0;
       while(n>0)
       {
         a+=n%10;
         n=n/10;          
      }
         n=a;
   }while(n>=10);
    return n;
}
int main()
{
    int p;
    while(1)
    {
        cin>>p;
        if(p) cout<<root(p)<<endl;
        else break;
    }
    
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator