Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import static java.lang.System.in;
- public class Demo {
- public static void main(String[] args) {
- Scanner console = new Scanner(in);
- int numOne = Integer.parseInt(console.nextLine());
- int numTwo = Integer.parseInt(console.nextLine());
- int magicNum = Integer.parseInt(console.nextLine());
- int combination = 0;
- boolean isFalse = false;
- for(int i = numOne; i >= numTwo; i--) {
- for (int j = numOne; j > numTwo; j--) {
- combination++;
- if (i + j == magic && !isFalse) {
- isFalse = true;
- System.out.printf("Combination N:%d (%d + %d = %d)",counter,i,j,magicNum);
- }
- }
- }
- if(IsFalse == false) {
- System.out.printf("%d combinations - neither equals %d", combination, magicNum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement