Advertisement
Guest User

Untitled

a guest
Feb 14th, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Pr02LettersCombinations {
  4.  
  5.     public static void main(String[] args) {
  6.         final Scanner scanner = new Scanner(System.in);
  7.  
  8.         char start = scanner.nextLine().charAt(0);
  9.         char end = scanner.nextLine().charAt(0);
  10.         char skip = scanner.nextLine().charAt(0);
  11.  
  12.         int combinationsCount = 0;
  13.        
  14.         for (char first = start; first <= end; first++) {
  15.             if (first == skip) {
  16.                 continue;
  17.             }
  18.             for (char second = start; second <= end; second++) {
  19.                 if (second == skip) {
  20.                     continue;
  21.                 }
  22.                 for (char third = start; third <= end; third++) {
  23.                     if (third == skip) {
  24.                         continue;
  25.                     }
  26.                     System.out.printf("%c%c%c ", first, second, third);
  27.                     combinationsCount++;
  28.                 }
  29.             }
  30.         }
  31.  
  32.         System.out.println(combinationsCount);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement