#include <stdio.h>
int main(void)
{
int days, hours, mins;
float a, b, c, total, temp, tempA, tempB;
a = 3.56;
b = 12.50;
c = 9.23;
total = a+b+c;
days = total / 24;
temp = total/24 - days;
hours = temp * 24;
tempA = temp*24 - hours;
mins = tempA*60;
while (hours >= 24)
{
hours= hours-24;
days +=1;
}
while ( mins >= 60)
{
mins=mins-60;
hours +=1;
}
printf("days:%d\n", days);
printf("hours:%d\n", hours);
printf("mins:%d\n", mins);
return 0;
}
小数の時間をリアルタイムに変換したかったのですが、それは問題なく実行できますが、時間が24を超え、分が60分を超える場合は、日数を増やしたいと思いました。whileループは減算し、新しい値を出力しますが、時間/日は合成されません。1日1時間77分1日2時間17分読みたかったのですが、1日1時間17分です。