Advertisement
Dilyana86

Untitled

May 1st, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import java.util.Scanner;
  2. import static java.lang.System.in;
  3.  
  4. public class Demo {
  5. public static void main(String[] args) {
  6. Scanner console = new Scanner(in);
  7. int numOne = Integer.parseInt(console.nextLine());
  8. int numTwo = Integer.parseInt(console.nextLine());
  9. int magicNum = Integer.parseInt(console.nextLine());
  10. int combination = 0;
  11. boolean isFalse = false;
  12. for(int i = numOne; i >= numTwo; i--) {
  13. for (int j = numOne; j > numTwo; j--) {
  14. combination++;
  15. if (i + j == magic && !isFalse) {
  16. isFalse = true;
  17. System.out.printf("Combination N:%d (%d + %d = %d)",counter,i,j,magicNum);
  18. }
  19. }
  20. }
  21. if(IsFalse == false) {
  22. System.out.printf("%d combinations - neither equals %d", combination, magicNum);
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement