Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int startNumber = Integer.parseInt(scanner.nextLine());
- int endNumber = Integer.parseInt(scanner.nextLine());
- int magicNumber = Integer.parseInt(scanner.nextLine());
- int combination = 0;
- for (int i = startNumber; i <= endNumber; i++) {
- for (int j = startNumber; j <= endNumber; j++) {
- combination++;
- if (i + j == magicNumber) {
- System.out.printf("Combination N:%d (%d + %d = %d)", combination, i, j, magicNumber);
- return;
- }
- }
- }
- System.out.printf("%d combinations - neither equals %d", combination, magicNumber);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement