c语言-pta-L-018大ben钟问题

#include <stdio.h>
int main()
{
int h,m,i;
int count;
scanf("%d:%d",&h,&m);
count=h-12;
if(h<=11||(h==12&&m==0))
printf("Only %02d:%02d. Too early to Dang.\n",h,m);
else
if(m!=0)
{
count++;
for(i=0;i<count;i++)
printf("Dang");
}
return 0;
}
这是PTA平台中L1-018大ben钟问题,中间有一个测试点答案错误,我找不到是哪里的问题请各位大lao帮忙看看、,多谢多谢



if (m != 0) 要放else 的_{} 中

你题目的解答代码如下:

#include <stdio.h>
int main()
{
    int h, m, i;
    int count;
    scanf("%d:%d", &h, &m);
    count = h - 12;
    if (h <= 11 || (h == 12 && m == 0))
        printf("Only %02d:%02d.  Too early to Dang.\n", h, m);
    else 
    { 
        if (m != 0)  //放else_{} 中
            count++;
        for (i = 0; i < count; i++)
            printf("Dang");
    }
    return 0;
}

img

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632