borovaneca

LetterCombinations

Nov 30th, 2022
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. package PBMore.WhileLoop.NestedLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class LettersCombination {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String one = scanner.nextLine();
  10.         String two = scanner.nextLine();
  11.         String tree = scanner.nextLine();
  12.         char on1 = one.charAt(0);
  13.         char on2 = two.charAt(0);
  14.         char on3 = tree.charAt(0);
  15.         int count = 0;
  16.  
  17.         for (char i = on1; i <= on2; i++) {
  18.             for (char j = on1; j <= on2; j++) {
  19.                 for (char k = on1; k <= on2; k++) {
  20.                     if (!(k == on3) && !(j == on3) && !(i == on3)){
  21.                         System.out.printf("%c%c%c ", i,j,k);
  22.                         count++;
  23.                     }
  24.                 }
  25.             }
  26.         }
  27.         System.out.print(count);
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment