I have a problem that the code below gives me the correct result, but when I send it to the site it informs the RUNTIME error (vector or array with less capacity than necessary for the problem, or when you try to access an invalid memory.) I can not see the reason for the error, could anyone help me?
exercise site for viewing: link
Console.Write("Dia ");
int diaI = int.Parse(Console.ReadLine());
// vetor string dados ínicio da festa
string line = Console.ReadLine();
string[] tempoI = line.Split(':');
int horaI = int.Parse(tempoI[0]);
int minI = int.Parse(tempoI[1]);
int segI = int.Parse(tempoI[2]);
Console.Write("Dia ");
int diaF = int.Parse(Console.ReadLine());
// vetor string dados encerramento da festa
string line2 = Console.ReadLine();
string[] tempoF = line2.Split(':');
int horaF = int.Parse(tempoF[0]);
int minF = int.Parse(tempoF[1]);
int segF = int.Parse(tempoF[2]);
int diaT = 0, horaT = 0, minT = 0, segT = 0;
//lógica para verificar tempo
{
//segundos
if (segI > segF)
segT = (60 - segI) + segF;
else if (segI == segF)
segT = 0;
else
segT = segF - segI;
//minutos
if (minI > minF)
minT = (60 - minI) + minF;
else if (minI == minF)
minT = 0;
else
minT = minF - minI;
//hora
if (horaI > horaF)
{
horaT = (24 - horaI) + horaF;
diaT = (diaF - diaI) - 1;
}
else if (horaI == horaF)
{
horaT = 0;
diaT = (diaF - diaI) + 1;
}
else
{
horaT = horaF - horaI;
diaT = (diaF - diaI);
}
}
//imprimindo
Console.WriteLine("{0} dia(s)", diaT);
Console.WriteLine("{0} hora(s)", horaT);
Console.WriteLine("{0} minuto(s)", minT);
Console.WriteLine("{0} segundo(s)", segT);