Answered step by step
Verified Expert Solution
Question
1 Approved Answer
When I put my code, I only got 75points. I guess that's because my while condition has something problem. Help me to write it c
When I put my code, I only got 75points. I guess that's because my while condition has something problem.
Help me to write it c code.
PD1 E-learning Wrong Answer (75/100) CLOSE A UPLOAD FILE O UPLOAD FROM GITHUB A UPLOAD FROM GITLAB HAPPY PARTY TRAIN 1 int fire(struct Car* head) { 2 int count=0; 3 Medium AC Ratio: 13.9% (255/1835) 4 #lf/else #Loop #Pointers #Struct 5 head = head->next; while(head->next!=NULL) { One tourist train is departing, and it's powered by a steam locomotive. Unfortunately, when passengers holding a party in cars, 7 8 9 the coal used as fuel in the back of the locomotive is on fire, burning red. 10 11 And every car contains different number of flammable items. if(head->passenger>=head->flammable) return count; else{ head->next->passenger += head->passenger; head = head->next; count++; } When passengers see the fire coming, they try to move these items to prevent fire burn to their car. 12 13 14 15 If number of peoples in the car >= amounts of flammable items, fire will not burn to this car and the following cars. 16 17 } return count; Otherwise, passengers in this car will evacuate to the the next car. 18 } Now you know the number of people & flammable items in each car, Please calculate how many cars will be burnt by fire. This train is represented with linked-list, each Car node's next will point to the next car , last cat will points to NULL Compile Message Head car Car 1 Car 2 passenger passenger SUBMIT Send Testing Submission X flammable flammable next next next Your code will be verified by the main file below #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started