70分!不知错在哪里???

P2010 [NOIP2016 普及组] 回文日期

dyx05221129 @ 2024-06-24 17:26:13

#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int date1, date2;
int monthday[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 30, 31, 31, 30, 0};
int sum;//92200229
int main()
{
    cin >> date1 >> date2;
    for(int i = 1 ; i <= 12; i++)
    {
        for(int j = 1; j <= monthday[i]; j++)
        {
            int q, p, qp;//i = 2, j = 28    q = 2*100 + 28 = 228    8200*10000 = 82000228   
            q = j%10*1000 + j/10*100 + i%10*10 + i/10;
            p = j%10 + j/10*10 + i%10*100 + i/10*1000;
            qp = q * 10000 + p;
            if(qp >= date1 && qp <= date2)
            {
                sum ++;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

by 迟暮天复明 @ 2024-06-24 17:34:06

你是不是没判闰年


|