it's my code
int main()
{
int n,m;
scanf_s("%d 시 %d 분에 알람을 맞춥니다. ",&n,&m);
if(m<45)
{
m +=15;
n--;
if(n<0) n+=24;
printf("%d 시 %d 분에 실제로 알람이 울리게 됩니다.",n,m);
}
}
It's answer
int main()
{
int a, b;
scanf_s("%d %d", &a, &b);
if (b < 45)
{
b += 60;
a--;
if (a < 0) a = 23;
}
printf("%d %d", a, b - 45);
}
The code above is a system that lets you ring 45 minutes earlier if you set an alarm.
If I compile it with my code and enter 0:35, the correct answer is 23: -858993445.
The answer below is normal output at 23:50
I think my answer is overflowing and I don't know why this is the result.
I want you to tell me why.
scanfformat string? You must match that exactly in your input. Please make it a habit to check whatscanf(etc.) returns.