Advertisement
JOHNYTHEWINNER

Number in string atoi

Feb 8th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. # include <iostream>
  2. using namespace std;
  3. #include <iomanip>
  4. #include <math.h>
  5. #include <cmath>
  6. #include <string>
  7. int main()
  8. {
  9.     string temp;
  10.     cin >> temp;
  11.     int sum = 0;
  12.     do {
  13.         int num = atoi(temp.c_str());
  14.         sum += num;
  15.         cin >> temp;
  16.     } while (temp != "Stop");
  17.     cout << sum << endl;
  18.  
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement