Stock-order processing
Stock-order processing
IGCSE 0478 · Algorithm writing
Read the question below and attempt it before opening support. Use the specified input/output contract. Check runs several independent cases; one sample output is not enough.
Difficulty 5/5 · 400 coins + a small bonus on first completion today
Stock is 9. Requests are 4, 0, 6, 5. A positive request is accepted only if it fits. Give Stock after each request.
Difficulty 5/5 · 400 coins + a small bonus on first completion today
With Stock = 5, valid request quantities are 1 to 5. Give four boundary test quantities in ascending order, including just-outside values.
Difficulty 5/5 · 400 coins + a small bonus on first completion today
Read initial Stock (non-negative), NumberOfRequests (1 to 6), then NumberOfRequests requested quantities. A request must be positive and no greater than current Stock. For each request output accepted and subtract it, or rejected and leave Stock unchanged. Finally output Stock.
Click Run to see the output here.