文章

4

粉丝

34

获赞

1

访问

1.2k

头像
日期计算 题解:
P1051 中南大学机试题
发布于2024年3月18日 22:40
阅读数 251

#include <stdio.h>
struct node
{
    int year,month,day;
}p;
int f[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
    while (scanf("%d %d %d",&p.year,&p.month,&p.day)!=EOF)
    {
        if ((p.year%400==0)||(p.year%4==0&&p.year%100==0))
        {
            f[2]=29;
        }
        else    
            f[2]=28;
        int flag=0;
        if (p.year<0||p.month>12||p.month<1||p.day<1||p.day>f[p.month])
        {
            printf("Input error!\n");
        }
        else{
            int sum=0;
            for (int i = 1; i ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发