Hey I am trying to make a C program which delays or sets airplane landing times. I have a problem with delaying the times. Here is the function which I am trying to do it :
Code:int canGoDown() { int time[24]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24}; for(int i=0; i<28; i++) { for(int j=0; j<24;j++) { if(time[j] == 0) { plane[i].landingTime += 1; } else { plane[i].landedTime = plane[i].landingTime; time[j] = 0; } } } }
I am basically trying to set the landing times. If the landing time is 0 it will delay the flight by one hour and try again. If it is anything else it will set the time to that and set the time to 0 which represents occupation.
My input file tells me when will the flights land for example a plane will land at 14:00 if the time is occupied it should try to land it on 15:00 if that is occupied it should try to land at 16:00 etc. This function currently returns all zeroes. For example if one plane is set to land at 14:00 no other plane should be able to land at time. So all the other planes which will land at 14:00 should be delayed until they find an empty hour to land. Currently there is 28 planes and I am trying to make it to work for only one day. So 4 of the planes will never land. I tried so many things since last night but I couldn't get it to work. Here is the excel file of the landing times of the planes and when should they land : https://flic.kr/p/2mQmaSa
I think it is a great logic but it doesn't work. I think I have a problem on setting the loops. If i can get any help i'd be so happy.
My input.txt is below.