统计信息

  • 访问数:14068
  • 博客数:143
  • 建立时间:2008-01-05
  • 更新时间:2008-10-15
我叫王超然,是一名电脑爱好者,现在在新加坡留学上高一.我立志成为一名电脑人才,愿意在这里与大家一同分享我玩转电脑的心得.O-level华文考了A-One哈哈!

P4Q11

2008-02-15 08:59:29

天气: 晴朗 心情: 高兴

/*P4Q11
 * Name:Wang Chaoran
 * Description:(Displaying leap years) Write a program that displays all the leap years,
  ten per line, in the twenty-first century (from 2001 to 2100).
  */
class P4Q11
{
  public static void main(String[]args)
  {
    int count = 0;
    System.out.println("All the leap years, ten per line, in the twenty-first century (from 2001 to 2100): ");
    //Calculate the leap year
    for(int i=2001;i<=2100;i++)
    {
     
      if(((i%4==0)&&(i%100!=0))||(i%400==0))
      {
        count++;
        //Display the leap year
        if(count%8==0)
        {
          System.out.println();
      
        }
        else
        {
           System.out.printf("%-5d",i);
        }
        }
    }
  }
}

加入收藏 编辑 审核

TAG: computing

我来说两句

OPEN

Powered by X-Space 1.2 © 2001-2006 Comsenz Technology Ltd