<C>.计算日期到天数转换

<C>.计算日期到天数转换,第1张

<C>.计算日期到天数转换
#include
int runyearpanduan(int x)
{
    if ((x % 4 == 0 && x % 100 != 0) || (x % 400 == 0))
    {
        return 1; //闰年
    }
    else
    {
        return 0;//平年
    }
}
int main()
{
    int year = 0;
    int month = 0;
    int days = 0;
    int i = 0;
    scanf("%d %d %d", &year,&month,&days);
    int runyear = 0;
    runyear = runyearpanduan(year);
    int run[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
    int ping[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
    int sum = 0;
    if (runyear == 1)
    {
        for (i = 0; i < month - 1; i++)
        {
            sum = sum + run[i];
        }
        sum = sum + days;
        printf("%d", sum);
    }
    if (runyear == 0)
    {
        for (i = 0; i < month - 1; i++)
        {
            sum = sum + ping[i];
        }
        sum = sum + days;
        printf("%d", sum);
    }
    return 0;
}

//英文拼音无缝切换,哈哈哈哈哈

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5714693.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-18

发表评论

登录后才能评论

评论列表(0条)

保存