TOPIC

Wrong Answer 100%

smsourav asked 3 years ago

Hello I am Sourav. I almost finished the problem but judge showing me 100% wrong answer where the program is almost correct.

#include <stdio.h>

int main()
{
    int h, m, hp, mp;
    while(scanf("%d%d", &h, &m)!=EOF)
    {
        if(h==0 && m==0)
        {
            hp = 0; mp = 0;
        }
        else if(h==360 && m==360){
            hp = 0; mp = 0;
        }
        else{
            hp = h/30; mp = m/6;
        }
        printf("%02d:%02d\n", hp, mp);
        if(h==0 && m==0)
        {
            break;
        }
    }
    return 0;
}

Remember not post solutions. Your post may be reviewed by our moderators.

  • wsalvatore replied 3 years ago

    aqui você está quebrando o laço quando H = M = 0.

    if(h==0 && m==0)
            {
                break;
            }

    porém o programa deve acabar apenas com o fim do arquivo(EOF

  • rodrigofaslima replied 8 months ago

    hp = h / 30; mp = m / 6;

    0 / 30 = 0; 0 / 6 = 0;

    360 / 30 = 12; 360 / 6 = 60;

  • electricircuits replied 3 years ago

    the minute counting should be like this

    1. for 0 to 5, the resultant should be same as minute.
    2. for greater than or equal to 6, resultant should be (m\6)+(m%6)