Advertisement
wigllytest

Untitled

Aug 8th, 2020
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <climits>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.  
  10.  
  11.  
  12. int sumSteps = 0;
  13. int stepsInt = 0;
  14.  
  15.  
  16. while (sumSteps < 10000)
  17. {
  18. string steps;
  19. getline(cin, steps);
  20. //cin.ignore();
  21.  
  22. // cin >> steps;
  23.  
  24. if (steps != "Going home")
  25. {
  26. stepsInt = stoi(steps);
  27. sumSteps += stepsInt;
  28. if (sumSteps >= 10000)
  29. {
  30. cout << "Goal reached! Good job!";
  31. break;
  32. }
  33. //cin >> steps;
  34.  
  35. }
  36. else
  37. {
  38. cin >> steps;
  39. stepsInt = stoi(steps);
  40. sumSteps += stepsInt;
  41.  
  42. if (sumSteps < 10000)
  43. {
  44. sumSteps = 10000 - sumSteps;
  45. cout << sumSteps << " more steps to reach goal.";
  46. }
  47. else
  48. {
  49. cout << "Goal reached! Good job!";
  50. }
  51. break;
  52. }
  53.  
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement