Output all daffodils

From , 5 Years ago, written in Java, viewed 205 times.
URL https://pastebin.vip/view/3fb451ca
  1. package hwoneweek;
  2. //在控制台输出所有的“水仙花数”
  3. public class flower{
  4.         public static void main(String[] args){
  5.                 int sum = 0;
  6.                 for(int i = 100;i <=999;i++){
  7.                         int a = i%10;
  8.                         int b = (i/10)%10;
  9.                         int c = i/100;
  10.                         sum = a*a*a+b*b*b+c*c*c;
  11.                         if(sum==i)
  12.                                 System.out.println(sum);                                               
  13.                 }
  14.                 System.out.println("以上即为所有的“水仙花数”!");      
  15.         }      
  16. }

Reply to "Output all daffodils"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website