Accepted solution

URI 1061 Solution

Open original problem
Source code

int main()

{

    int d=0, h=0, m=0, s=0, ds, hs, ms, ss, de, he, me, se;

    char a[4], b[2];

    scanf("%s %d", &a, &ds);

    scanf("%d %s %d %s %d", &hs, &b, &ms, &b, &ss);

    scanf("%s %d", &a, &de);

    scanf("%d %s %d %s %d", &he, &b, &me, &b, &se);

    d = de-ds;

    h = he-hs;

    if(h<0)

    {

        h+=24;

        d-=1;

    }

    m = me-ms;

    if(m<0)

    {

        m+=60;

        h-=1;

    }

    s = se-ss;

    if(s<0)

    {

        s+=60;

        m-=1;

    }

    printf("%d dia(s)
%d hora(s)
%d minuto(s)
%d segundo(s)
", d, h, m, s);

    return 0;

}
Join the discussion

Add your comment