c语言,倒数第3和第1个结果错误,求勘误

P5707 【深基2.例12】上学迟到

qiuren @ 2024-10-29 15:35:57

#include <stdio.h>
int main()
{
    int s, v, arrivalhour, arrivalmin, endmin, beginmin, beginhour;
    double travelmin, totaltravel;
    scanf("%d %d", &s, &v);
    arrivalhour = 8;
    arrivalmin = 0;
    travelmin = (double)s / v;
    totaltravel = travelmin + 10;
    endmin = arrivalhour * 60 + arrivalmin;
    beginmin = (int)(endmin - totaltravel);
    while (beginmin < 0) {
        beginmin += 1440;
    }
    beginhour =(int)(beginmin / 60);
    beginmin =(beginmin) % 60;
    printf("%02d:%02d\n", beginhour, beginmin);
    return 0;
}

|