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

谁能帮我看看哪里错了?

Posted by summery at 2006-04-05 21:52:59 on Problem 1519
#include<iostream>
using namespace std;

long digital (long n )
{
    int sum  = 0;
    sum = n%10;
    n = n/10;
    while(n !=0)
    {
      sum += n%10;
      n = n/10;      
    }
    if(sum <10)
    return sum;
    else return digital(sum); 
}

int main()
{
    long n = -1;
    
    while(cin>>n&& n!=0)
    {
      cout<< digital(n)<<endl;             
    }
    
}

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