文章

33

粉丝

42

获赞

3

访问

7.3k

头像
日期差值 题解:
P1290 上海交通大学/西北工业大学2019机试
发布于2024年3月12日 11:29
阅读数 292

#include <stdio.h>
struct date {
    int year;
    int month;
    int day;
}p, q;
int main() {
    int year, month, day;
    int f[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
    int pre = 0, post = 0;
    int gap = 0;
    scanf("%4d%02d%02d", &p.year, &p.month, &p.day);
    scanf("%4d%02d%02d", &q.year, &q.month, &q.day);
    //same year
    if (p.year == q.year) {
        if ((p.year % 4 == 0 && p.year % 100 != 0) || p.year % 400 == 0) 
            f[2] = 29;
        for (int i = 0;i < p.month;i++)
            pre += f[i];
        pre += p.day;
 &n...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发