Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- using namespace std;
- unsigned int k = 0, cnt = 0;
- int F(string s, int iter);
- int main()
- {
- string str;
- unsigned int sumPos = 0;
- getline(cin, str);
- while (k < str.length())
- {
- if (isdigit(str[k]))
- sumPos += F(str, k);
- else
- k++;
- }
- cout << sumPos;
- return 0;
- }
- int F(string s, int iter)
- {
- string sLoc = "";
- int pos = 0,sumLoc;
- while (isdigit(s[iter]))
- {
- sLoc += s[iter];
- iter++;
- pos++;
- }
- k += pos;
- char* str = new char[pos];
- sumLoc = atoi(sLoc.c_str());
- return sumLoc;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement