-
2018-07-28 15:58:40
import
calendar
>>> calendar.monthrange(
2018
,
7
)[
1
]
31
>>> calendar.monthrange(
2018
,
2
)[
1
]
28
其中下表0为 星期几
更多相关内容 -
判断一个月有多少天
2013-04-15 11:01:43输入一个年份和月份,打印该月有多少天。 用c语言编写。。能在vc下运行 -
java通过年月判断这个月有几天
2018-01-09 18:41:29通过年月判断这个月有几天,闰年2月有29天,输入年份,月,判断是否闰年 -
用switch语句判断每个月有多少天
2012-07-30 18:24:15用switch语句编写的小程序,判断每个月有多少天。 -
判断某年某月有多少天(C语言)
2021-05-20 07:20:30本文带来各类奇怪的IT百科知识。从键盘输入某年某月:包括...已知闰年的2月有29天:平年有28天。#include :stdio.h:int main() {int year,month;scanf(:%d %d:,:year,:month);printf(:Please enter year and...本文带来各类奇怪的IT百科知识。
从键盘输入某年某月:包括闰年::用switch语句编程输出该年的改月拥有的天数。要求考虑闰年以及输入月份不在合法范围内的情况。已知闰年的2月有29天:平年有28天。
#include :stdio.h:
int main() {
int year,month;
scanf(:%d %d:,:year,:month);
printf(:Please enter year and month :);
if((year%4::0 :: year%100!:0 ) || year%400::0 ){ //判断是否是闰年
switch (month) {
case 2: 29;
printf(:There are 29 days in this month:);
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
printf(:There are 31 days in this month:);
break;
case 4:
case 6:
case 9:
case 11:
printf(:There are 30 days in this month:);
break;
}
} else{
switch (month) {
case 2: 28;
printf(:There are 28 days in this month:);
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
printf(:There are 31 days in this month:);
break;
case 4:
case 6:
case 9:
case 11:
printf(:There are 30 days in this month:);
break;
}
}
return 0;
}
-
输入年、月,判断该月有多少天
2021-12-24 00:44:271 引言月是历法中的一种时间单位,传统上都是以月相变化周期作为一个月的长度。农历中大小月出现的规律是以朔望月为准的,大月30天,小月29天,大月小月相互弥补,使历月的平均长度接近朔望月。然...1 引言
月是历法中的一种时间单位,传统上都是以月相变化周期作为一个月的长度。农历中大小月出现的规律是以朔望月为准的,大月30天,小月29天,大月小月相互弥补,使历月的平均长度接近朔望月。然而2月既不是大月,也不是小月,
2月的天数是以该年是否为闰年来判断天数
2 问题描述
请输入年份:2008
请输入月份:2
输出:本月有29天
3 算法描述
从键盘中输入年份和月份,用if语句将天数为31天的月份表示出来,然后将天数为30天的月份也表示出来,接着在判断2月的天数,用if条件语句判断出2月且年份为闰年的,输出天数为29天,其余则为28天。
4 结语
本文探讨了and,or的用法、判断闰年的方法以及if条件语句的运用,进一步巩固了有关判断闰年以及if条件语句的知识点,让我对if条件语句以及判断闰年的更加的得心应手。
代码清单 1
year=int(input('请输入年份:'))
month=int(input('请输入月份:'))
if month==1 or month==3 or month==5 or month==7 or month==8 or month==10 or month==12:
print('该月有31天')
elif month==4 or month==6 or month==9 or month==11:
print('该月有30天')
elif month==2 and (year % 400 == 0 or (year % 4 == 0 and year % 100 != 0)):
print('该月有29天')
else:
print('该月有28天')实习编辑:李欣容
稿件来源:深度学习与文旅应用实验室(DLETA)
-
输入年份和月份,输出该月有多少天,判断这一天是该年的第几天
2020-12-13 10:19:53你是要思路还是要代码?#includeusing ... // 判断是不是闰年int dayOfMonth(int year, int month); // 判断某一年某一个月份的天数int main() {int year, month, day;int index = 0;cin >> year >&...你是要思路还是要代码?
#include
using namespace std;
bool Leap_Year(int year); // 判断是不是闰年
int dayOfMonth(int year, int month); // 判断某一年某一个月份的天数
int main() {
int year, month, day;
int index = 0;
cin >> year >> month;
cout > year >> month >> day;
for (int i = 1; i < month; i ) {
index = dayOfMonth(i);
}
index = day;
cout << index << endl; // 输出这一天是这一年第几天。
return 0;
}
bool Leap_Year(int year) {
if ((year@0 == 0) || ((year%4 == 0)&&(year0 != 0)))
return true;
else
return false;
}
int dayOfMonth(int year, int month) {
if (month == 2) {
if (Leap_year(year)) return 29;
else return 28;
}
switch (month) {
-
如何用Python判断某年某月有多少天
2019-06-28 16:32:33输入年、月,输出本月有多少天。合理选择分支语句完成设计任务 输入样例1:2004 2 输出结果1:本月29天 输入样例2:2010 4 输出结果2:本月30天 代码: year = int(input('Year:')) month = int(input('Month:')) ... -
Java——输入某年某月, 判断这个月有多少天?
2020-04-28 19:01:27判断这个月有多少天? import java.util.Calendar; import java.util.Scanner; public class CalendarDemo { public static void main(String[] args) { String dateString = new Scanner(Syste... -
Java 输入月份判断该月份有多少天
2020-12-16 15:44:02Java 输入月份判断该月份有多少天 int year=2020,month=12;//定义变量记录年月 if(month==2) { //判断年是不是闰年 if((year%4==0&&year%100!=0)||(year%400==0)) { System.out.println(year+"年"+... -
python判断某一年的某个月有多少天
2019-03-21 17:28:45一个整数代表此年此月的天数 例 Input: 2017 10 Output: 31 代码: year=int(input("请输入年份:")) month=int(input("请输入月份:")) day=0 if month in (1,3,5,7,8,10,12): day=31 p... -
JS switch 输入一个月份 判断该月有多少天
2019-04-23 13:55:061、接收用户数据 var year = parseInt(prompt('请您输入一个年份', 2000)); var month = parseInt(prompt('请...2、判断每个月有多少天,记录每个月的天数 var day = 0; switch (month) { case 1: case 5: ... -
Java输入年份与月份判断月份有多少天
2020-09-13 14:21:33* 输出这一年这一月一共有多少天 * 比如: * 输入:2019年8月 * 输出:2019年8月一共有31天 *31天的月:1 3 5 7 8 10 12 *30天的月:4 6 9 11 * *2月:闰年:29天 平年:28天 * *判断闰年公式 * :可以... -
判断当前月有多少天
2017-03-08 17:03:46如下代码 //获取月份天数 int GetMonthDayCount(int year,int month) { switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: { return 31;... case -
Java程序判断某一年的某个月有多少天
2019-03-31 00:28:45链接地址 https://jingyan.baidu.com/article/19020a0a2b6f18529d2842cf.html -
python脚本:输入年、月,输出本月有多少天【if条件判断练习】
2019-06-25 15:15:18输入年、月,输出本月有多少天。 输入样例:2004 2 输出结果:本月 29天 输入样例:2010 4 输出样例:本月30天 考查内容: if条件判断的应用 闰年逻辑判断 代码实现: Year = int(input('请输入年份: ... -
C 判断 —— switch语句(输入的年份判断是否为闰年,根据输入的月份判断这月有多少天)
2018-10-31 17:53:35使用 switch 语句编程,根据输入的年份判断是否为闰年,根据输入的月份判断这月有多少天。 #include<stdio.h> int main() { int year, month, ex; printf("请输入年份及月份(空格分隔):&... -
js 根据年月判断有多少天
2019-03-12 14:25:14需求:根据不同得年份和月份判断该月有多少天 //根据年月得到天数 getDayNumByYearMonth:function (year,month){ switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: ... -
判断某年某月有多少天
2017-09-04 10:02:20判断某年某月有多少天的简便方法 -
js判断当前日所在月份有多少天
2020-05-25 20:55:35判断当前日期所在月份有多少天 分析: 先使用getMonth()得到改日所在月份; 根据获得的月份加一得到下一个月; 使用setDate()指定一个日期对象的天数,指定0时,那么日期就会被设置为上个月的最后一天 此时已经得到... -
判断某一年是否是闰年,计算某一年的二月有多少天
2019-06-27 18:41:46闰年的二月有29天,非闰年二月有28天,要想判断某一年是否是闰年,就是计算某一年的二月有多少天 代码如下 import java.util.Calendar; import java.util.Scanner; public class FebruaryDay { public static void... -
#输入年份和月份,用Python判断这年这月有多少天
2019-05-24 08:42:00#日常笔记 while True: def isLeep(y): result = y%4==0 and y%100!=0 or y%400==0 return result days = [0,31,28,31,30,31,30,31,31,3... -
C++switch语句 | 判断某年某月有几天
2020-11-27 21:16:28C++多分支选择结构 ... } } 执行本程序之后 输入年份和月份,年月之间用空格隔开 2020 10 2020年是闰年 你输入的10月有31天 判断某年是否使闰年,并且判断这年的某月有几天。 更多案例可以go公众号:C语言入门到精通 -
让用户输入一个年份和月份,然后判断这个月有多少天
2019-09-29 06:51:43#include #include ... 闰年的2月份有29天 ...月有 " " 天 " endl; system( " pause " ); return 0 ; } 转载于:https://www.cnblogs.com/tanghaiyong/p/11371893.html -
根据输入的月份值,判断当月有多少天
2018-07-25 22:54:23练习:根据用户传递的月份值,判断当前月有多少天。如果是2月,根据用户传输的年份,判断2月的天数。switch 和if两种方法 方法一:public class IfTest{ public static void main(String args[]){ int month ... -
简单编程(四)要求用户输入一个年份和一个月份,判断该年该月有多少天。
2021-03-15 15:23:12要求用户输入一个年份和一个月份,判断该年该月有多少天。Java 编程貌似这个程序有点 复杂了 嘿嘿import javax.swing.JOptionPane;public class mm {/*** @param args*/public static void main(String[] args) {// ... -
C#版--判断一个月有多少天
2015-03-24 08:11:59用switch语句实现,与C语言不同的是,default后必须增加break语句 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace dataOper ... static void Main(s -
输入一个年份,一个月份,打印某年某月有多少天(需要判断是否为闰年)
2020-09-04 15:05:04输入一个年份,一个月份,打印某年某月有多少天(需要判断是否为闰年)