Advertisement
Guest User

Help..?

a guest
Apr 24th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1.   // game loop
  2.         while (true) {
  3.             int count = in.nextInt(); //
  4.             String closestEnemy = "";
  5.             int minDist = 1000;
  6.             for (int i = 0; i < count; i++) {
  7.             String enemy = in.next(); // The name of this enemy
  8.             int dist = in.nextInt(); // The distance to your canon of this enemy
  9.             if(dist <= minDist) {
  10.                 minDist = dist;
  11.                 closest Enemy = enemy;
  12.             }
  13.     }   <- this one
  14.            
  15.             System.out.println(closestEnemy); //
  16.     }   <- this one too
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement