#! usr/bin/env python
# -*- coding: utf-8 -*-
import sys
class CDate:
days = (0,30,28,31,30,31,30,31,31,30,31,30,31)
def __init__(self,y,m,d):
self.year = y
self.month = m
self.day = d
def setDate(self,y,m,d):
self.year = y
self.month = m
self.day = d
def printDate(self):
print '%d/%d/%d' % (self.year,self.month,self.day)
def isLeapYear(self):
return (self.year % 400 == 0) or (self.year % 4 == 0 and self.year % 100 != 0)
def tomorrow(self):
d = self.days[self.month]
if self.month == 2 and self.isLeapYear() : d += 1
self.day += 1
if self.day > d :
self.month += 1
self.day = 1
if self.month > 12 :
self.year += 1
self.month = 1
return self
if __name__ == '__main__' :
CDate(2000,2,28).tomorrow().printDate()
CDate(2000,2,29).tomorrow().printDate()
CDate(2000,12,31).tomorrow().printDate()
CDate(2001,2,28).tomorrow().printDate()
CDate(2000,3,5).tomorrow().printDate()
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/63d0f703918fa0ec14fb401c249759ee3d6ddbe6?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
追问很感谢 但是我看不懂 我刚学习C++ 您能不能帮我编个基础的
追答我晕,他说字数超过限制了,我弄在附件里面了!是C++的!
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/bd3eb13533fa828bb87638f2ff1f4134970a5a4d?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)