Advertisement
Guest User

Letters Combinations

a guest
May 1st, 2017
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Task6181216 {
  3.     public static void main(String[] args){
  4.  
  5.         int combinations=0;
  6.         char startChar, endChar, excludeChar;
  7.         Scanner scanner = new Scanner(System.in);
  8.         StringBuilder sb = new StringBuilder();
  9.  
  10.         startChar  = scanner.nextLine().charAt(0);
  11.         endChar  = scanner.nextLine().charAt(0);
  12.         excludeChar  = scanner.nextLine().charAt(0);
  13.  
  14.  
  15.         for (char i = startChar; i <= endChar ; i++) {
  16.             if (i==excludeChar){
  17.                 continue;
  18.             }
  19.             for (char j = startChar; j <= endChar ; j++) {
  20.                 if (j==excludeChar){
  21.                     continue;
  22.                 }
  23.                 for (char k = startChar; k <= endChar ; k++) {
  24.                     if (k==excludeChar) {
  25.                         continue;
  26.                     }
  27.                     combinations++;
  28.                     sb.append(i);
  29.                     sb.append(j);
  30.                     sb.append(k);
  31.                     sb.append(" ");
  32.  
  33.                 }
  34.  
  35.             }
  36.  
  37.         }
  38.         System.out.print(sb.toString());
  39.         System.out.println(combinations);
  40.  
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement