Advertisement
andkamen

four numbers

Feb 18th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. package com.Ch1_ArraysAndStrings;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class FourNumbers {
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.  
  9.         int a = Integer.parseInt(scan.nextLine());
  10.         int b = Integer.parseInt(scan.nextLine());
  11.  
  12.         boolean printedAny = false;
  13.  
  14.         for (int i = a; i <= b; i++) {
  15.             for (int j = i+1; j <=b ; j++) {
  16.                 for (int k = j+1; k <=b ; k++) {
  17.                     for (int l = k+1; l <=b ; l++) {
  18.                         printedAny = true;
  19.                         System.out.printf("%d %d %d %d\n",i,j,k,l);
  20.                     }
  21.                 }
  22.             }
  23.         }
  24.  
  25.         if (!printedAny){
  26.             System.out.println("No");
  27.         }
  28.  
  29.     }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement