0
I have a problem that the code below it results me the correct result, however, when I send to the site it informs the error RUNTIME (vector or array with less capacity than required for the problem, or when you try to access an invalid memory. ) I can’t see the reason for the mistake, someone could help me??
Exercise website for viewing: https://www.urionlinejudge.com.br/judge/pt/problems/view/1061
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);
It may be a matter of Culture, as the default date format on the server is different, such as MM/dd/YYYY
– Leandro Angelo
Opa leandro, as so matter of culture, because as the site debugs the code I think this would not interfere or not??
– Lukas_Russo
Pera, what you mean by send to the site, what you have is a console application
– Leandro Angelo