想法

#include <stdio.h>
#include <stdlib.h>

int year1,month1,day1;
int year2,month2,day2;
int ans=0;

int normal_months[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int lunar_months[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};

int lunar_or_not(int);
int sum(int, int, int);

int lunar_or_not(int year){
    if (year%4==0 && year%100!=0 || year%400==0){
        return 1; // 該年為潤年
    }
    else{
        return 0;
    }
}

int sum(int year,int month, int day){
    int total_days=0;
    
    // 加總年份的天數
    for (int i = 1; i < year; i++){
        if (lunar_or_not(i) == 1)
        {
            total_days+=366;
        }
        else{
            total_days+= 365;
        }
    }
    // 加總月份的天數
    for(int i=0;i<month;i++){
        if(lunar_or_not(year) == 1){
            total_days+=lunar_months[i];
        }else{
            total_days+=normal_months[i];
        }
    }
    
    total_days+=day;
    
    return total_days;
}

int main(){
    
    while(scanf("%d %d %d",&year1,&month1,&day1)!=EOF){
        scanf("%d %d %d",&year2,&month2,&day2);
    
        ans=abs(sum(year1,month1,day1)-sum(year2,month2,day2));
        printf("%d\\n",ans);
    }
    return 0;
}