borkins

Exam Jan-2016 - 11. Increasing 4 Numbers

May 11th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. /**
  2.  * Project: Exam_101_January_2016 - created by borkins on 2017-05-03.
  3.  */
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class _11_IncreasingFourNumbers
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.         Scanner console = new Scanner(System.in);
  12.        
  13.         int a = Integer.parseInt(console.nextLine());
  14.         int b = Integer.parseInt(console.nextLine());
  15.        
  16.         int n1;
  17.         int n2 = a + 1;
  18.         int n3 = a + 2;
  19.         int n4 = a + 3;
  20.        
  21.         if (Math.abs(a - b) >= 3)
  22.         {
  23.             for (n1 = a; n1 <= n2 - 1; n1++)
  24.             {
  25.                 for (n2 = n1 + 1; n2 <= n3 - 1; n2++)
  26.                 {
  27.                     for (n3 = n2 + 1; n3 <= n4 - 1; n3++)
  28.                     {
  29.                         for (n4 = n3 + 1; n4 <= b; n4++)
  30.                         {
  31.                             System.out.printf("%d %d %d %d%n", n1, n2, n3, n4);
  32.                         }
  33.                     }
  34.                 }
  35.             }
  36.         }
  37.         else {
  38.             System.out.println("No");
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment