Advertisement
xTheEc0

CodinGame.com // Onboarding // Tutorial

Oct 22nd, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. /**
  9.  * CodinGame planet is being attacked by slimy insectoid aliens.
  10.  * <---
  11.  * Hint:To protect the planet, you can implement the pseudo-code provided in the statement, below the player.
  12.  **/
  13. int main()
  14. {
  15.  
  16.     // game loop
  17.     while (1) {
  18.         string enemy1; // name of enemy 1
  19.         int dist1; // distance to enemy 1
  20.         cin >> enemy1; cin.ignore();
  21.         cin >> dist1; cin.ignore();
  22.        
  23.         string enemy2; // name of enemy 2
  24.         int dist2; // distance to enemy 2
  25.         cin >> enemy2; cin.ignore();
  26.         cin >> dist2; cin.ignore();
  27.  
  28.         // Write an action using cout. DON'T FORGET THE "<< endl"
  29.         // To debug: cerr << "Debug messages..." << endl;
  30.  
  31.         if (dist1 < dist2) cout << enemy1 << endl;
  32.         else cout << enemy2 << endl;
  33.        
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement