輸入年月日計算是本年的第多少天

2021-10-01 14:14:59 字數 740 閱讀 2435

//平年28天,閏年29天

//下面這year函式判斷輸入的年份為閏年還是平年

function

year

(x)return

false;}

function

year

(y,m,d)

var arr =[31

,28,31

,30,31

,30,31

,31,30

,31,30

,31];

//將一年中的每個月的天數存入陣列,假設今年為平年

for(

var i =

0;i < m -

1;i++)if

(m >2)

}return

alert

(y +

"年"+ m +

"月"+ d +

"日是本年的第"

+ day +

"天");}

y =number

(prompt

("請輸入年"))

;m =

number

(prompt

("請輸入月"))

;d =

number

(prompt

("請輸入日"))

;console.

log(

year

(y, m, d));

輸入年月日,得到輸入的日期是該年的第多少天

記錄一下自己的 region 讓使用者輸入乙個年月日,輸出這一天是該年的第幾天 static void day console.writeline 請輸入月份 var mouth console.readline int resmouth isint mouth while resmouth 1 r...

輸入年月日,輸出這個日期是今年的第多少天

typedef struct date date 判斷是否為閏年 bool isleapyear int year 計算總天數 inttotaldays struct date da arr儲存每個月的天數if isleapyear da year 判斷是否為閏年 一直迴圈到當前月份的上一月份 fo...

判斷使用者輸入的年月日是當前年的第多少天

const rs require readline sync console.log 請輸入年份 let year rs.question 0 console.log 請輸入月份 let month rs.question 0 console.log 請輸入日期 let date rs.questi...