KeepCoding

LettersCombinations

Dec 7th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class LettersCombination {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.  
  7.         char start = console.nextLine().charAt(0);
  8.         char stop = console.nextLine().charAt(0);
  9.         char exclude = console.nextLine().charAt(0);
  10.  
  11.         int count = 0;
  12.  
  13.         for (char character1 = start; character1 <= stop; character1++) {
  14.             if (character1 == exclude) {
  15.                 continue;
  16.             }
  17.             for (char character2 = start; character2 <= stop; character2++) {
  18.                 if (character2 == exclude) {
  19.                     continue;
  20.                 }
  21.                 for (char character3 = start; character3 <= stop; character3++) {
  22.                     if (character3 != exclude) {
  23.                         System.out.printf("%c%c%c ", character1, character2, character3); // 80/100 лимит време на тест 3 и 10
  24. //                        System.out.print("" + character1 + character2 + character3 + " "); // 100/100
  25.                         count ++;
  26.                     }
  27.                 }
  28.             }
  29.         }
  30.         System.out.print(count);
  31.  
  32.         //main ends here
  33.     }
  34. }
Add Comment
Please, Sign In to add comment