Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P06ticketCombination {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int count = 1;
- int number = Integer.parseInt(scanner.nextLine());
- for (char i = 'B'; i <= 'L'; i += 2) {
- for (char j = 'f'; j >= 'a'; j--) {
- for (char k = 'A'; k <= 'C'; k++) {
- for (int l = 1; l <= 10; l++) {
- for (int m = 10; m >= 1; m--) {
- if (count == number) {
- int sum = (i + j + k) + l + m;
- String ticketCombination = "" + i + j +k +l + m;
- System.out.printf("Ticket combination: %s\n" +
- "Prize: %d lv.", ticketCombination, sum);
- return;
- }
- count++;
- }
- }
- }
- }
- }
- }
- }
- //import java.util.Scanner;
- //public class Main {
- // public static void main(String[] args) {
- // Scanner scanner = new Scanner(System.in);
- // int number = Integer.parseInt(scanner.nextLine());
- // int counter = 1;
- // for (char i = 'B'; i <= 'L'; i += 2) {
- // for (char j = 'f'; j >= 'a'; j--) {
- // for (char k = 'A'; k <= 'C'; k++) {
- // for (int l = 1; l <= 10; l++) {
- // for (int m = 10; m >= 1; m--) {
- // if (counter == number) {
- // int sum = (i + j + k) + (l + m);
- // System.out.printf("Ticket combination: %s%s%s%d%d%n", i, j, k, l, m);
- // System.out.printf("Prize: %d lv.", sum);
- // }
- // counter++;
- // }
- // }
- // }
- // }
- // }
- // }
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement