2019 autumn a Java test summary

1. printout of all the "number of Narcissus", the so-called "number Narcissus" means a 3-digit number, which is equal to the digits of the cube and the number itself. For example, 153 is a "number daffodils."
Experiments Source:
public class Flower{
      public static void main (String[] args){
      int x,y,z;
      for(int i=100;i<=999;i++){
        x=i/100;
        y=(i/100)/10;
        z=i%10;
        if(Math.pow(x,3)+Math.pow(y,3)+Math.pow(z,3)==i){
           System.out.println(i);
         }
      } 
   }
}   

The results:

2. Write a Java program, find the value of + 13-23 + 33-43 + 973-983 + 993-1003 of ...
Experiments Source:

Guess you like

Origin www.cnblogs.com/lxzlyf2022/p/11497595.html