mitakvd

Walking

Jul 7th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main () {
  7.  
  8.     int steps = 0;
  9.     string command;
  10.  
  11.     while (steps < 10000) {
  12.         getline(cin, command);
  13.         if (command == "Going home") {
  14.             getline(cin, command);
  15.             steps += stoi(command);
  16.             if (steps >= 10000) {
  17.                 cout << "Goal reached! Good job!" << endl;
  18.             } else {
  19.                 cout << 10000 - steps << " more steps to reach goal." << endl;
  20.             }
  21.             break;
  22.         }
  23.         steps += stoi(command);
  24.  
  25.         if (steps >= 10000) {
  26.             cout << "Goal reached! Good job!" << endl;
  27.             break;
  28.         }
  29.     }
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment