C++ 题解
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
char s;
int sum = 0;
while (cin >> s)
{
int num = 0;
if ((s >= '0') && (s <= '9'))
{
num = s - '0';
sum += num;
}
if (getchar() == '\n')
{
cout << sum << endl;
sum = 0;
}
}
return 0;
}
#include <stdio.h>
using namespace std;
int main()
{
char s;
int sum = 0;
while (cin >> s)
{
int num = 0;
if ((s >= '0') && (s <= '9'))
{
num = s - '0';
sum += num;
}
if (getchar() == '\n')
{
cout << sum << endl;
sum = 0;
}
}
return 0;
}