Advertisement
Asenov

Hit the Target

Mar 17th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class HitTheTarget {
  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         int n = input.nextInt();
  7.  
  8.         for (int c = 0; c < 2; c++) {
  9.             for (int i = 1; i <= 20; i++) {
  10.                 for (int j = 1; j <= 20; j++) {
  11.                     if (c < 1){
  12.                         if (i + j == n) {
  13.                             System.out.printf("%d + %d = %d\n", i, j, n);
  14.                         }
  15.                     }
  16.                     else {
  17.                         if (j - i == n) {
  18.                             System.out.printf("%d - %d = %d\n", j, i, n);
  19.                         }
  20.                     }
  21.                 }
  22.             }
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement