Advertisement
didatzi

maxCombination

Mar 11th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4.  * Created by Didatsy on 1.3.2017 г..
  5.  */
  6. public class ex06_maxCombination {
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         int startNum = Integer.parseInt(scanner.nextLine());
  11.         int endNum = Integer.parseInt(scanner.nextLine());
  12.         int maxCombination = Integer.parseInt(scanner.nextLine());
  13.         int combination = 0;
  14.  
  15.         for (int i = startNum; i <= endNum; i++) {
  16.             for (int j = startNum; j <=endNum ; j++) {
  17.                 combination++;
  18.                 if (combination>maxCombination){
  19.                     return;
  20.                 }
  21.                 System.out.printf("<%d-%d>",i ,j);
  22.             }
  23.  
  24.         }
  25.  
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement