skipter

Battles - Java Basics - Loops in loops

Apr 29th, 2017
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FOX {
  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.        int playerOnePokemons = Integer.parseInt(input.nextLine());
  7.        int playerTwoPokemons = Integer.parseInt(input.nextLine());
  8.        int maximumFights = Integer.parseInt(input.nextLine());
  9.        int count = 0;
  10.  
  11.         for (int i = 1; i <= playerOnePokemons; i++) {
  12.             for (int j = 1; j <= playerTwoPokemons; j++) {
  13.                 count++;
  14.                 if (count > maximumFights) {
  15.                    break;
  16.                 }
  17.                 System.out.printf("(%d <-> %d) ", i, j );
  18.             }
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment