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

尼玛,题目里面没提到要多大才行啊,我做个万能的,就不信了,居然让我提交3次

Posted by lisency at 2012-03-26 10:02:02 on Problem 1519 and last updated at 2012-03-26 10:04:35
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str;
    while (cin >> str && str.empty() == false && str[0] != '0')
    {
        int n = 0,sum = 0;
        for (int i = 0;i < str.size();i++)
        {
            n += str[i] - '0';
        }

        while (n != 0 || ((sum / 10) != 0 ?n = sum,sum = 0,1 : 0))
        {
            
            sum += n % 10;
            n = n / 10;
        }
        cout << sum << endl;
    }
    return 0;
}

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