0402.712 2022-11-29 17:22 采纳率: 100%
浏览 8
已结题

关于谭浩强c语言第九章第一题

如图,请问一下为什么运行到这儿就不运行了?

img


代码如下:

#include<stdio.h>

int a = 0, b, c, date1, two1 = 28, two2 = 29;

struct lun {
    int year;
    int month;
    int day;
}date;

int main()
{
    void judge(struct lun date);
    printf("please input your date:");
    scanf("%d %d %d", &date.year, &date.month, &date.day);
    judge(date);
    if (date.month <= 1)
        date1 = date.month * 31 + date.day;
    b = date.month / 2;
    c = date.month % 2;
    if (a == 1)
    {
        if (c != 0)
            date1 = (date.month - 1) * 30 + two2 + (b + 1);
        else
            date1 = (date.month - 1) * 30 + b + two2;
    }
    else
    {
        if (c != 0)
            date1 = (date.month - 1) * 30 + two1 + (b + 1);
        else
            date1 = (date.month - 1) * 30 + b +two1;
    }
    printf("the date is %s's %d day.", date.year, date1);
    return 0;
}

void judge(struct lun date)
{
    if (date.year % 4 == 0)
    {
        if (date.year % 100 != 0)
        {
            a = 1;
            printf("the year is a leap year.");
        }
        else
        {
            if (date.year % 400 == 0)
            {
                a = 1;
                printf("the year is a leap year.");
            }
            else
                printf("the year is not a leap year.");
        }
    }
    else
        printf("the year is not a leap year.");
}

  • 写回答

2条回答 默认 最新

  • 快乐鹦鹉 2022-11-29 17:26
    关注

    printf("the date is %s's %d day.", date.year, date1);
    改为
    printf("the date is %d's %d day.", date.year, date1);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 12月7日
  • 已采纳回答 11月29日
  • 创建了问题 11月29日

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测