Hello.
How can I create wihle for this ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
void plat (Pracovnici pracovnici[], CAS cas[], int velikost)
{
int CelkoveHodiny = 0;
int CelkoveMinuty = 0;
for (int i = 0; i < velikost2; i++)
{
CelkoveHodiny = cas[i].Pondeli_Hodiny + cas[i].Uteri_Hodiny + cas[i].Streda_Hodiny + cas[i].Ctvrtek_Hodiny + cas[i].Patek_Hodiny + cas[i].Sobota_Hodiny + cas[i].Nedele_Hodiny;
CelkoveMinuty = cas[i].Pondeli_Minuty + cas[i].Uteri_Minuty + cas[i].Streda_Minuty + cas[i].Ctvrtek_Minuty + cas[i].Patek_Minuty + cas[i].Sobota_Minuty + cas[i].Nedele_Minuty;
}
}
|
This is function I call and thi function sum arry of hours and minits.
And I need cycle if all sum of minits (CelkoveMinuty) is > 60.
All sum of hours + 1 (CelkoveHodiny)
All sum of minits - 60 (CelkoveMinuty)
until all sum of minits is < 60.
Here is for example data
8:00;8:00;4:30;2:30;7:00;0:00;8:00
Last edited on
Use modular arithmetic and assuming minutes are integers for simplicity:
hours = sum_minutes \ 60;
minutes = sum_minutes %60
for example if sum_minutes = 527 minutes
hours = 527\60 = 8 hours
and minutes = 527%60 = 47 minutes
So,
527 minutes = 8 hours 47 minutes.
Last edited on