herrDeng網內搜尋

自訂搜尋

Ads

2012年3月7日 星期三

閏年的判斷程式

請照下列台北天文台陽年閏年說明,寫一判斷輸入公元n年(n>0)是否為閏年的判斷程式。

陽曆曆法

臺灣目前使用的曆法為陰陽合曆。其中陽曆的部分,年的制訂是利用太陽的運動而來,1回歸年(或太陽年)實際長度為365.24219天,陽曆曆法上的1年長度為365天,每年會因而多出0.24219天(相當於5.8小時),如此一來,累積4年後為0.96876天,幾近1天,為修正之,故國曆曆法中有「閏年」制度,每4年會多2月29日這一天。

然而,累積4年後多的0.96876天,與真正的1日尚差0.03124天,故如果不間斷地按4年1閏的方式修正,百年後將累積成365×100+25=36525日,比真正的1世紀日數365.24219×100=36524.219多。

因此曆法學家便重新規定閏年的規則為:西元年份逢4的倍數閏、100的倍數不閏、400的倍數閏、4000的倍數不閏。例如:西元1992、1996年等為4的倍數,故為閏年;西元1700、1800、1900年為100的倍數,當年不閏年;西元1600、2000、2400年為400的倍數,有閏;而西元4000、8000年為4000的倍數,則不閏。

出處:http://tamweb.tam.gov.tw/news/2010/201002/news2010020904.htm

37 則留言:

B10033019 提到...

import java.util.*;
public class n {
public static void main(String[] args)
throws Exception
{
Scanner sc = new Scanner(System.in);
System.out.println("請輸入年份=> ");
int n = sc.nextInt();
if(n%4000==0)
System.out.println("平年");
else if (n%400==0)
System.out.println("閏年");
else if (n%100==0)
System.out.println("平年");
else if (n%4==0)
System.out.println("閏年");
else System.out.println("平年");
}
}

B10033011 提到...

import java.util.*;
public class useScanner {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
if(n%4000==0){
System.out.println("平年");
}
else if (n%400==0){
System.out.println("閏年");
}
else if (n%100==0){
System.out.println("平年");
}
else if (n%4==0){
System.out.println("閏年");
}
else
System.out.println("平年");
}
}

B10033052 提到...

import java.util.*;
public class useScanner{
public static void main(String[]args)
{
int n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
if(n%4000==0){
System.out.println("平年");
}
else if (n%400==0){
System.out.println("閏年");
}
else if (n%100==0){
System.out.println("平年");
}
else if (n%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033027 提到...

import java.util.*;
public class useScanner{
public static void main (String [] args){
int n;
Scanner SC=new Scanner (System.in);
n=SC.nextInt();
if(n%4000==0){
System.out.println("平");
}
else if (n%400==0){
System.out.println("閏");
}
else if (n%100==0){
System.out.println("平");
}
else if (n%4==0){
System.out.println("閏");
}
else {
System.out.println("平");
}
}
}

B10033036 提到...

import java.util.*;
public class useScanner {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
if(n%4000==0){
System.out.println("平年");
}
else if (n%400==0){
System.out.println("閏年");
}
else if (n%100==0){
System.out.println("平年");
}
else if (n%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033004 提到...

import java.util.*;
public class useScanner{
public static void main(String[]args)
{
int n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
if(n%4000==0){
System.out.println("平年");
}
else if (n%400==0){
System.out.println("閏年");
}
else if (n%100==0){
System.out.println("平年");
}
else if (n%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033056 提到...

import java.util.*;
public class useScanner{
public static void main(String[]args)
{
int n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
if(n%4000==0){
System.out.println("平年");
}
else if (n%400==0){
System.out.println("閏年");
}
else if (n%100==0){
System.out.println("平年");
}
else if (n%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033056 提到...

import java.util.*;
public class useScanner{
public static void main(String[]args)
{
int n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
if(n%4000==0){
System.out.println("平年");
}
else if (n%400==0){
System.out.println("閏年");
}
else if (n%100==0){
System.out.println("平年");
}
else if (n%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033040 提到...

import java.util.*;
public class useScanner{
public static void main(String[]args)
{
int n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
if(n%4000==0){
System.out.println("平年");
}
else if (n%400==0){
System.out.println("閏年");
}
else if (n%100==0){
System.out.println("平年");
}
else if (n%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033003 提到...

import java.util.*;
public class hello {

public static void main(String [] args) throws Exception {
Scanner sc=new Scanner(System.in);
System.out.println("請輸入年份=");
int n=sc.nextInt();
if(n%4000==0){
System.out.println("平");
}
else if(n%400==0){
System.out.println("閏");
}
else if(n%100==0){
System.out.println("平");
}
else if(n%4==0){
System.out.println("閏");
}
else{
System.out.println("平");
}

}
}

B10033025 提到...

import java.util.*;
public class hello {

public static void main(String [] args)throws Exception {
Scanner sc=new Scanner (System.in);
System.out.println(請輸入年份=");
if(n%4000==0){
System.out.println("平");
}
else if(n%400==0)}{
System.out.println("閏");
}
else if(n%100==0){
System.out.println("平");
}
else if(n%4==0){
System.out.println("閏");
}
else{
System.out.println("平");
}
}
}

B10033021 提到...

import java.util.*;
public class useScanner1 {

public static void main (String [] args) {
Scanner sc=new Scanner (System.in);
System.out.print("請輸入年份=>");
int year = sc.nextInt();
if(year%4000==0){
System.out.println("平年");
}
else if (year%400==0){
System.out.println("閏年");
}
else if (year%100==0){
System.out.println("平年");

}
else if (year%4==0){
System.out.println("閏年");

}
else System.out.println("平年");
}
}

B10033014 提到...

import java.util.*;
public class useScanner{
public static void main(String[]args)
{
int n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
if(n%4000==0){
System.out.println("平年");
}
else if (n%400==0){
System.out.println("閏年");
}
else if (n%100==0){
System.out.println("平年");
}
else if (n%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033020 提到...

import java.util.*;

public class hello {

public static void main(String[] args) {

java.util.Scanner sc =

new java.util.Scanner(System.in);

System.out.print("請輸入西年年份");

int i = sc.nextInt();

if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){

System.out.println("閏年");
}
else if (i%100==0){

System.out.println("平年");
}

else if (i%4==0){

System.out.println("閏年");
}

else{

System.out.println("平年");
}
}
}

B10033005 提到...

import java.util.*;

public class hello {

public static void main(String[] args) {

java.util.Scanner sc =

new java.util.Scanner(System.in);

System.out.print("請輸入西年年份");

int i = sc.nextInt();

if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){

System.out.println("閏年");
}
else if (i%100==0){

System.out.println("平年");
}

else if (i%4==0){

System.out.println("閏年");
}

else{

System.out.println("平年");
}
}
}

b9833163 提到...

import java.util.*;

public class hello {

public static void main(String[] args) {

java.util.Scanner sc =

new java.util.Scanner(System.in);

System.out.print("請輸入西年年份");

int i = sc.nextInt();

if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){

System.out.println("閏年");
}
else if (i%100==0){

System.out.println("平年");
}

else if (i%4==0){

System.out.println("閏年");
}

else{

System.out.println("平年");
}
}
}

B10033026 提到...

import java.util.*;

public class good {

public static void main(string[] args) {

Scanner sc = new java.util.Scanner(System.in);

int i = sc.nextInt();

if( i%4000==0)
System.out.println("平年");
else if (i%400==0)
System.out.println("閏年");
else if (i%100==0)
System.out.println("平年");
else if (1%4==0)
System.out.println("閏年");
else
System.out.println("平年");

b10033017 提到...

import java.util.*;

public class hello {

public static void main(String[] args) {

java.util.Scanner sc =

⋯⋯ new java.util.Scanner(System.in);

System.out.print("請輸入西年年份");

int i = sc.nextInt();

if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){

System.out.println("閏年");
}
else if (i%100==0){

System.out.println("平年");
}

else if (i%4==0){

System.out.println("閏年");
}

else{

System.out.println("平年");
}
}
}

B10033016 提到...

import java.util.*;

public class Test {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("請輸入西元元年份:");
while( sc.hasNext() ){
int a = sc.nextInt();
if( (a % 4 == 0 && a % 100 != 0) || a % 400 == 0 )
System.out.println("閏年");
else
System.out.println("平年");
System.out.println("請輸入西元元年份:");
}

}
}

B10033002 提到...

import java.util.*;
public class yy {
public static void main(String[] args) {
java.util.Scanner sc =

new java.util.Scanner(System.in);
System.out.print("請輸入西年年份:");
int i = sc.nextInt();
if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){
System.out.println("閏年");
}
else if (i%100==0){
System.out.println("平年");
}
else if (i%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033043 提到...

import java.util.*;
public class yy {
public static void main(String[] args) {
java.util.Scanner sc =

new java.util.Scanner(System.in);
System.out.print("請輸入西年年份");
int i = sc.nextInt();
if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){
System.out.println("閏年");
}
else if (i%100==0){
System.out.println("平年");
}
else if (i%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033001 提到...

import java.util.*;

public class hello {

public static void main(String[] args) {

java.util.Scanner sc =

new java.util.Scanner(System.in);

System.out.print("請輸入西年年份");

int i = sc.nextInt();

if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){

System.out.println("閏年");
}
else if (i%100==0){

System.out.println("平年");
}

else if (i%4==0){

System.out.println("閏年");
}

else{

System.out.println("平年");
}
}
}

B10033057 提到...

import java.util.*;
public class test {
public static void main(String[] args) {
java.util.Scanner sc =
newjava.util.Scanner(System.in);
System.out.print("請輸入西年年份");
int i = sc.nextInt();
if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){
System.out.println("閏年");
}
else if (i%100==0){
System.out.println("平年");
}
else if (i%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033013 提到...

import java.util.*;
public class test {
public static void main (String [] args) {
java.util.Scanner sc=
new java.util.Scanner(System.in);
System.out.print("請輸入年份");
int n=sc.nextInt();
if (n%4000==0) {
System.out.println("平年");
}
else if (n%400==0) {
System.out.println("閏年");
}
else if (n%100==0) {
System.out.println("平年");
}
else if (n%4==0) {
System.out.println("閏年");
}
else {
System.out.println("平年");
}
}
}

B10033054 提到...

import java.util.*;
public class hello {
public static void main(String[] args) {
java.util.Scanner sc =

new java.util.Scanner(System.i​n);
System.out.print("請輸入西年年份"​);
int n = sc.nextInt();
if( n%4000==0) {
System.out.println("平年");
}
else if (n%400==0){
System.out.println("閏年");
}
else if (n%100==0){
System.out.println("平年");
}
else if (n%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033009 提到...

import java.util.*;
public class hello {
public static void main(String[] args) {
java.util.Scanner sc =

new java.util.Scanner(System.i​n);
System.out.print("請輸入西年年份"​);
int i = sc.nextInt();
if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){
System.out.println("閏年");
}
else if (i%100==0){
System.out.println("平年");
}
else if (i%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033045 提到...

import java.util.*;
public class hello{
public static void main(String[] args) {
java.util.Scanner sc =

new java.util.Scanner(System.i​n);
System.out.print("請輸入西年年份"​);
int i = sc.nextInt();
if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){
System.out.println("閏年");
}
else if (i%100==0){
System.out.println("平年");
}
else if (i%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033022 提到...

import java.util.*;
public class Hello{
public static void main(String[] args) {
java.util.Scanner sc =

new java.util.Scanner(System.in);
System.out.print("請輸入西年年份");
int i = sc.nextInt();
if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){
System.out.println("閏年");
}
else if (i%100==0){
System.out.println("平年");
}
else if (i%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033048 提到...

import java.util.*;
public class yy {
public static void main(String[] args) {
java.util.Scanner sc =

new java.util.Scanner(System.in);
System.out.print("請輸入西年年份");
int i = sc.nextInt();
if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){
System.out.println("閏年");
}
else if (i%100==0){
System.out.println("平年");
}
else if (i%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

b10033037 提到...

import java.util.*;
public class hello {
public static void main(String[] args) {
java.util.Scanner sc =

new java.util.Scanner(System.in);
System.out.print("請輸入西年年份");
int i = sc.nextInt();
if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){
System.out.println("閏年");
}
else if (i%100==0){
System.out.println("平年");
}
else if (i%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B9833080 提到...

import java.util.Scanner;

public class year{
public static void main(String[] args){
int year = 0;
Scanner scanner = new Scanner(System.in);
System.out.printf("請輸入西洋年:");
year= scanner.nextInt();
if(year % 4 == 0){
if(year % 100 ==0){
if( year % 400 ==0){
if( year % 4000 ==0)
System.out.printf("%d 是平年哦",year);
else
System.out.printf("%d 是閏年耶...",year);
}
else
System.out.printf("%d 是平年哦",year);
}
else
System.out.printf("%d 是閏年耶...",year);
}
else
System.out.printf("%d 是平年哦",year);
}

}

B10033035 提到...

import java.util.*;
public class n {
public static void main(String[] args)
throws Exception
{
Scanner sc = new Scanner(System.in);
System.out.println("請輸入年份=> ");
int n = sc.nextInt();
if(n%4000==0)
System.out.println("平年");
else if (n%400==0)
System.out.println("閏年");
else if (n%100==0)
System.out.println("平年");
else if (n%4==0)
System.out.println("閏年");
else System.out.println("平年");
}
}

b10033039 提到...

import java.util.*;
public class hello {
public static void main(String[] args) {
java.util.Scanner sc =

new java.util.Scanner(System.in);
System.out.print("請輸入西年年份");
int i = sc.nextInt();
if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){
System.out.println("閏年");
}
else if (i%100==0){
System.out.println("平年");
}
else if (i%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033030 提到...

import java.util.*;
public class test {
public static void main(String[] args) {
java.util.Scanner sc =

new java.util.Scanner(System.in);
System.out.print("請輸入西年年份");
int i = sc.nextInt();
if( i%4000==0) {
System.out.println("平年");
}
else if (i%400==0){
System.out.println("閏年");
}
else if (i%100==0){
System.out.println("平年");
}
else if (i%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B10033044 提到...

import java.util.*;
public class useScanner{
public static void main(String[]args)
{
int n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
if(n%4000==0){
System.out.println("平年");
}
else if (n%400==0){
System.out.println("閏年");
}
else if (n%100==0){
System.out.println("平年");
}
else if (n%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

b10033028 提到...

import java.util.*;
public class useScanner{
public static void main(String[]args)
{
int n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
if(n%4000==0){
System.out.println("平年");
}
else if (n%400==0){
System.out.println("閏年");
}
else if (n%100==0){
System.out.println("平年");
}
else if (n%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

B9733205 提到...

import java.util.*;
public class tred {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
if(n%4000==0){
System.out.println("平年");
}
else if (n%400==0){
System.out.println("閏年");
}
else if (n%100==0){
System.out.println("平年");
}
else if (n%4==0){
System.out.println("閏年");
}
else{
System.out.println("平年");
}
}
}

Related Posts Plugin for WordPress, Blogger...

熱門文章