#include <bits/stdc++.h>
using namespace std;
long long int q, sum;
int cnt[10000005];
int s;
bool cmp, cmp2;
long long int num = 1;
string a;
stringstream ss;
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
while (getline(cin, a))
{
ss.str("");
for (long long int i = 0; i < a.length(); i++)
{
if (a[i] == ' ')
{
cnt[num] = i;
if (cmp2)
{
a.erase(cnt[num - 1], cnt[num] - cnt[num - 1]);
cmp2 = 0;
i -= (cnt[num] - cnt[num - 1]);
cnt[num] -= (cnt[num] - cnt[num - 1]);
}
num++;
}
if (s == 1 && a[i]<'0' || a[i]>'9')
{
cmp2 = 1;
}
}
ss << a;
while (ss >> q)
{
sum += q;
}
cout << sum << '\n';
sum = 0;
q = 0;
s = 0;
num = 1;
cmp = 0, cmp2 = 0;
memset(cnt, 0, sizeof(cnt));
ss.clear();
}
}
當發現單字有非數字的字元,就刪除那個單字
不知道問題在哪裡,各位大大求解!!!!!!!