Advertisement
finderabc

06.Сбор или Произведение Exam - 25 June 2017

Jun 25th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class 06.Сбор или Произведение  {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner in = new Scanner(System.in);
  7.         int m = Integer.parseInt(in.nextLine());
  8.         int count = 0;
  9.         for (int d1 = 1; d1 <= 30; d1++) {
  10.             for (int d2 = 1; d2 <= 30; d2++) {
  11.                 for (int d3 = 1; d3 <= 30; d3++) {
  12.                         if ((m == (d1*d2*d3)) && ((d1 > d2) && (d2 > d3))) {
  13.                             System.out.printf("%d * %d * %d = %d%n", d1, d2, d3, m);
  14.                             count++;
  15.                         } else if ((m == d1 + d2 + d3) && ((d1 < d2) && (d2 < d3))) {
  16.                             System.out.printf("%d + %d + %d = %d%n", d1, d2, d3, m);
  17.                             count++;
  18.                         }
  19.                        
  20.                 }
  21.             }
  22.                    
  23.         }
  24.         if (count == 0) {
  25.             System.out.println("No!");
  26.         }
  27.                
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement