能被 4 整除,但不能被 100 整除;能被 4 整除,又能被 100.docVIP

  • 483
  • 0
  • 约3.17万字
  • 约 30页
  • 2018-09-28 发布于江苏
  • 举报

能被 4 整除,但不能被 100 整除;能被 4 整除,又能被 100.doc

能被 4 整除,但不能被 100 整除;能被 4 整除,又能被 100

1.编写一个类的方法,判断某一年是否为闰年。闰年的条件是符合下面二者之一:能被 4 整除,但不能被 100 整除;能被 4 整除,又能被 100 整除。 import java.util.Scanner; public class isLeapYear{ public static void main(String[] args){ Scanner input = new Scanner(System.in); int num = input.nextInt(); if((num%400==0)||(num%100!=0num%4==0)){ System.out.println(num+是瑞年); } else{ System.out.println(num+不是瑞年); } } } 2.编写程序打印出所有的水仙花数(水仙花数是三位的整数)。 public class shuiXianHua { public static void main(String[] args) { for(int i=100;i=999;i++){ int a=i/100; int b=i/10%10; int c=i%100%10; if(a

文档评论(0)

1亿VIP精品文档

相关文档