欢迎来到天天文库
浏览记录
ID:12581255
大小:677.50 KB
页数:12页
时间:2018-07-17
《面向对象程序设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、第一题/***************************************************宋文隽作业第一题*内容包括闰平年判断,2月天数判断4,6,9,11月判断。输入日期累加i天后日期的判断***************************************************/#include#include#defineuintunsignedintints(intc){intleap;if(c%400==0
2、
3、(c%4==0&&c%100!=0))//判断是不是
4、闰年leap=1;elseleap=0;returnleap;}classdata{public:data(){cout<<"输入完日期回车"<>year;while(0>=year){cout<<"输入年数有误,请确定年数范围"<>year;}if(s(year)){cout<<"闰年"<5、KEmonth=";cin>>month;while(0>=month6、7、month>12){cout<<"输入月数有误,请确定月数范围"<>month;}cout<<"MAKEday=";cin>>day;if(month==48、9、month==610、11、month==912、13、month==11){while(0>=day14、15、day>30){cout<<"输入天数有误,请确定天数范围,此月最多30天"<16、;cout<<"MAKEday=";cin>>day;};}while(0>=day17、18、day>31){cout<<"输入天数有误,请确定天数范围"<>day;}if(month==2&&s(year)==1){while(0>=day19、20、day>29){cout<<"输入天数有误,请确定天数范围此月最多29天"<>day;};}elseif(month==2&&s(year)==0){w21、hile(0>=day22、23、day>28){cout<<"输入天数有误,请确定天数范围此月最多28天"<>day;};}}voiddisplay(){unsignedcharmon[12][13]={"January","February","March","April","May","June","July","August","September","October","November","December"};cout<<"thedayis="<24、25、th==12){if(day==31){year++;month=1;day=1;}else{day++;}}elseif(month==2){if(s(year)){if(day==29){month++;day=1;}else{day++;}}else{if(day==28){month++;day=1;}else{day++;}}}elseif(month==426、27、month==628、29、month==930、31、month==11){if(day==30){month++;day=1;}else{day++;}}}}setdata(){cout<32、<"thedayisreset."<
5、KEmonth=";cin>>month;while(0>=month
6、
7、month>12){cout<<"输入月数有误,请确定月数范围"<>month;}cout<<"MAKEday=";cin>>day;if(month==4
8、
9、month==6
10、
11、month==9
12、
13、month==11){while(0>=day
14、
15、day>30){cout<<"输入天数有误,请确定天数范围,此月最多30天"<16、;cout<<"MAKEday=";cin>>day;};}while(0>=day17、18、day>31){cout<<"输入天数有误,请确定天数范围"<>day;}if(month==2&&s(year)==1){while(0>=day19、20、day>29){cout<<"输入天数有误,请确定天数范围此月最多29天"<>day;};}elseif(month==2&&s(year)==0){w21、hile(0>=day22、23、day>28){cout<<"输入天数有误,请确定天数范围此月最多28天"<>day;};}}voiddisplay(){unsignedcharmon[12][13]={"January","February","March","April","May","June","July","August","September","October","November","December"};cout<<"thedayis="<24、25、th==12){if(day==31){year++;month=1;day=1;}else{day++;}}elseif(month==2){if(s(year)){if(day==29){month++;day=1;}else{day++;}}else{if(day==28){month++;day=1;}else{day++;}}}elseif(month==426、27、month==628、29、month==930、31、month==11){if(day==30){month++;day=1;}else{day++;}}}}setdata(){cout<32、<"thedayisreset."<
16、;cout<<"MAKEday=";cin>>day;};}while(0>=day
17、
18、day>31){cout<<"输入天数有误,请确定天数范围"<>day;}if(month==2&&s(year)==1){while(0>=day
19、
20、day>29){cout<<"输入天数有误,请确定天数范围此月最多29天"<>day;};}elseif(month==2&&s(year)==0){w
21、hile(0>=day
22、
23、day>28){cout<<"输入天数有误,请确定天数范围此月最多28天"<>day;};}}voiddisplay(){unsignedcharmon[12][13]={"January","February","March","April","May","June","July","August","September","October","November","December"};cout<<"thedayis="<
24、25、th==12){if(day==31){year++;month=1;day=1;}else{day++;}}elseif(month==2){if(s(year)){if(day==29){month++;day=1;}else{day++;}}else{if(day==28){month++;day=1;}else{day++;}}}elseif(month==426、27、month==628、29、month==930、31、month==11){if(day==30){month++;day=1;}else{day++;}}}}setdata(){cout<32、<"thedayisreset."<
25、th==12){if(day==31){year++;month=1;day=1;}else{day++;}}elseif(month==2){if(s(year)){if(day==29){month++;day=1;}else{day++;}}else{if(day==28){month++;day=1;}else{day++;}}}elseif(month==4
26、
27、month==6
28、
29、month==9
30、
31、month==11){if(day==30){month++;day=1;}else{day++;}}}}setdata(){cout<
32、<"thedayisreset."<
此文档下载收益归作者所有