文章

40

粉丝

607

获赞

68

访问

419.5k

头像
1545时间戳
P1545 杭州电子科技大学机试题
发布于2020年2月24日 16:15
阅读数 7.9k

#include<iostream>
#include<iomanip> 

using namespace std;

int ping[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
int run[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31 };

void time(int year, int month, int day, int count) {

	while (count > 0) {
		count--;
		if (month == 12 && day == 31) {
			year++;
			month = 1;
			day = 1;
			continue;
		}
		else if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
			if (day == run[month]) {
				month++;
				day = 1;
				continue;
			}
			else {
				day++;
				continue;
			}
		}
		else {
			if (day == ping[month]) {
				month++;
				day = 1;
				continue;
			}
			else {
				day++;
				continue;
			}
		}
	}
	cout << year << "-" << setfill('0') << setw(2) << month << "-" << setfill('0') << setw(2) << day << " ";
}

int main() {
	int count;
	while (cin >> count) {
		int hour, min, sec;
		se...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发