TheBulgarianWolf

All possible increasing combinations of 4 nums

Mar 18th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main
  3. {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.         System.out.print("Enter \"a\" here: ");
  7.         int a = Integer.parseInt(sc.nextLine());
  8.         System.out.print("Enter \"b\" here: ");
  9.         int b = Integer.parseInt(sc.nextLine());
  10.         int count = 0;
  11.         for(int i = a;i<=b;i++){
  12.             for(int j = i+1;j<=b;j++){
  13.                 for(int k = j+1;k<=b;k++){
  14.                     for(int h = k+1;h<=b;h++){
  15.                         System.out.println(String.format("%d %d %d %d",i,j,k,h));
  16.                         count++;
  17.                     }
  18.                 }
  19.             }
  20.         }
  21.        
  22.         if(count == 0){
  23.             System.out.println("No");
  24.         }
  25.        
  26.     }
  27.    
  28.    
  29. }
Add Comment
Please, Sign In to add comment