|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- temp = input('请输入一个年份:')
- while not temp.isdigit():
- temp = input("抱歉,您的输入有误,请输入一个整数:")
- year = int(temp)
- if year/400 == int(year/400):
- print(temp + ' 是闰年!')
- else:
- if (year/4 == int(year/4)) and (year/100 != int(year/100)):
- print(temp + ' 是闰年!')
- else:
- print(temp + ' 不是闰年!')
复制代码
与
- temp = input('请输入一个年份:',)
- while not temp.isdigit():
- temp = input('你要输入一个数字哦:')
- year = int (temp)
- if year/4 == int(year/4):
- print(temp + '是闰年')
- else:
- print(temp + '不是闰年')
复制代码
有什么不同吗,后者更加容易呀
目前使用的格里高利历闰年规则如下[1]:
公元年分非4的倍数,为平年。
公元年分为4的倍数但非100的倍数,为闰年。
公元年分为100的倍数但非400的倍数,为平年。
公元年分为400的倍数,为闰年。
|
|