Czy ktoś może mi wytłumaczyć dlaczego przy przesyłaniu odpowiedzi do zadania Obżartuchy dostaję błąd wykonania SIGFPE?
Przez test przeszedł następujący kod:
#include <iostream>
using namespace std;
int numberofguests, cookiesinbox, numberoftests, numberofboxes, howmanycookiesforallguests;
float boxfloat;
int main()
{
cin >> numberoftests;
for (int i = 1; i <= numberoftests; i++)
{
howmanycookiesforallguests = 0;
cin >> numberofguests >> cookiesinbox;
int* guesteatingspeed = new int[numberofguests];
for (int i = 0; i <= numberofguests; i++)
{
cin >> guesteatingspeed[i];
howmanycookiesforallguests += 86400 / guesteatingspeed[i];
}
if (howmanycookiesforallguests <= cookiesinbox)
numberofboxes = 1;
else
{
boxfloat = howmanycookiesforallguests / cookiesinbox;
if (howmanycookiesforallguests % cookiesinbox != 0)
numberofboxes = (int)boxfloat + 1;
else
numberofboxes = boxfloat;
}
cout << numberofboxes << endl;
}
return 0;
}
Jeżeli jest ktoś w stanie naprawić ten błąd i wskazać błędny kod to będę wdzięczny za odpowiedź.
created
last reply
- 1
reply
- 245
views
- 2
users
- 2
likes
- 1
link