文章
27
粉丝
86
获赞
10
访问
30.4k
C++
果然是同一所大学的题,和1437差不多。不过就是加1天改为了加past天
原题:1437 - 日期类 _N诺计算机考研 (noobdream.com)
我的1437做法:日期类 题解:_P1437_N诺计算机考研 (noobdream.com)
#include <iostream>
#include <iomanip>
using namespace std;
bool isLeapYear(int year){
return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
}
void show(int year, int month, int day, int past){
for(int i = 0; i < past; i++){
if(month == 12 && day == 31){
year += 1;
month = 1;
day = 1;
}
else if((month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10) && day == 31){
month += 1;
day = 1;
}
else if((month == 4 || month == 6 || month == 9 || month == 11) && day == 30){
month += 1;
day = 1;
}
else if(month == 2 && day == 29 && isLeapYear(year)){
month += 1;
day = 1;
}
else if(month == 2 && day == 28 && !isLeapYear(year)){
month += 1;
day = 1;
}...
登录后发布评论
暂无评论,来抢沙发