JS——输入一个日期判断该日期为当年的第几天
let read =require("readline-sync"); console.log("输入年份"); let year=read.question(""); console.log("输入月份"); let mon=read.question(""); console.log("输入日期"); let day=parseInt(read.question("")) let num=0 switch (mon-1) { case 11:num+=30; case 10:num+=31; case 9: num+=30; case 8: num+=31; case 7: num+=31; case 6: num+=30; case 5: num+=31; case 4: num+=30; case 3: num+=31 case 2:{ if (year%4==0) { num+=29; }else{ num+=28 } } case 1:num+=31 } console.log(num + day+"天");