search

Home  >  Q&A  >  body text

Java - Output the product of all three integers between 4 unequal integers

Write a program in Java to output the product of any three integers between 4 unequal integers.
For example, input 1,7,3,4
calculation process:
734,134,174 ,173
Output: 84,12,28,21

阿神阿神2744 days ago672

reply all(1)I'll reply

  • 仅有的幸福

    仅有的幸福2017-05-17 10:02:37

    int[] arr = {1,4,3,7};
    for(int i = 0;i< arr.length;i++){
       int num = 1;
       for(int j= 0; j<arr.length;j++){
           if(i!=j){
              num = num * arr[j];
           }
       }
    
       System.out.println(num);
    }

    reply
    0
  • Cancelreply