如题所述
第1个回答 2010-10-26
#include <iostream>
using namespace std;
void main()
{
int x, n = 0, sum = 0;
cin >> x;
if (x == 0)
n = 1;
while (x>0) {
sum += x % 10;
x /= 10;
n++;
}
cout << n << ' ' << sum;
}本回答被提问者采纳
using namespace std;
void main()
{
int x, n = 0, sum = 0;
cin >> x;
if (x == 0)
n = 1;
while (x>0) {
sum += x % 10;
x /= 10;
n++;
}
cout << n << ' ' << sum;
}本回答被提问者采纳