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 |
尼玛,题目里面没提到要多大才行啊,我做个万能的,就不信了,居然让我提交3次#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator