Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #include <sstream>
- bool isAllDigit(string inword);
- int main ()
- {
- string input;
- while(getline(cin,input))
- {
- int sum=0;
- stringstream wholeline(input);
- while(wholeline)
- {
- string word;
- wholeline >> word;
- if(isAllDigit(word))
- {
- sum += atoi(word.c_str());
- }
- }
- cout<<sum<<endl;
- }
- return 0;
- }
- bool isAllDigit(string inword)
- {
- bool alldigit=1;
- for(int i=0;i<inword.length();i++)
- {
- if(!isdigit(inword[i]))
- {
- alldigit=0;
- break;
- }
- }
- return alldigit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement