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 |
谁能帮我看看哪里错了?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator