#include <stdio.h>
#include <conio.h>
int main()
{
int hour=4,min=58,sec=37,nopa,nevisande,zaman=-1;
printf("\nHow many coins does nopa have at start?");
scanf("%d",&nopa);
printf("\nHow many coins does nevisande have at start?");
scanf("%d",&nevisande);
while(nopa!=nevisande)
{
zaman++;
//stepping the clock
sec++;
if(sec==60)
{
sec=0;
min++;
}
if(min==60)
{
min =0;
hour++;
}
if(hour==24)
{
hour = 0;
}
//end of stepping
//nopa gives some coins to nevisande
if(sec%2==1)
{
nopa--;
nevisande++;
}
if((sec/10)%2==1)
{
nopa--;
nevisande++;
}
if(min%2==1)
{
nopa--;
nevisande++;
}
if((min/10)%2==1)
{
nopa--;
nevisande++;
}
if(hour%2==1)
{
nopa--;
nevisande++;
}
if((hour/10)%2==1)
{
nopa--;
nevisande++;
}
//end of nevisande coins
//nevisande gives some coins to nopa
if(sec%10 == 0)
{
nevisande -=4;
nopa +=4;
}
if(sec/10 == 0)
{
nevisande -=4;
nopa +=4;
}
if(min%10 == 0)
{
nevisande -=4;
nopa +=4;
}
if(min/10 == 0)
{
nevisande -=4;
nopa +=4;
}
if(hour%10 == 0)
{
nevisande -=4;
nopa +=4;
}
if(hour/10 == 0)
{
nevisande -=4;
nopa +=4;
}
}//end of while
printf("\nThey would become equal in %d seconds.",zaman+1);
getch();
return 2010;
}