Професионална програма
Loading...
DimovIvan avatar DimovIvan 11 Точки

C++Advanced-Stacks and Queues - Exercise, Fast Food - няколко въпроса

You have a fast food restaurant and most of the food that you're offering is previously prepared. You need to know if you will have enough food to serve lunch to all of your customers. Write a program that checks the orders’ quantity. You also want to know the client with the biggest order for the day, because you want to give him a discount the next time he comes. 

First, you will be given the quantity of the food that you have for the day (an integer number).  Next, you will be given a sequence of integers, each representing the quantity of an order. Keep the orders in a queue. Find the biggest order and print it. You will begin servicing your clients from the first one that came. Before each order, check if you have enough food left to complete it. If you have, remove the order from the queue and reduce the amount of food you have. If you succeeded in servicing all of your clients, print: 

"Orders complete".

 If not, print:

"Orders left: {order1} {order2} .... {orderN}".

Input

On the first line you will be given the quantity of your food - an integer in the range [0, 1000]

On the second line you will receive a sequence of integers, representing each order, separated by a single space

Output

Print the quantity of biggest order

Print "Orders complete" if the orders are complete

If there are orders left, print them in the format given above

Constraints

The input will always be valid

Examples

 

Input                                        Output    

348                                          54

20 54 30 16 7 9                       Orders complete

 

Input                                         Output  

499                                           90

57 45 62 70 33 90 88 76          Orders left: 76 

 

1. Програмата ми сработва когато подам двата входа на един ред. Когато са на отделни редове, както е в условието, вторият ред изобщо не        ми го прочита(т.е. не ми дава да напълня контейнера). Не знам как да го оправя това.

2. Някъде бъркам във service функцията защото винаги ми занулява sumOrders и ми изпразва контейнера, и на printSolution винаги ми дава        резултат: Orders complete

https://pastebin.com/22zhRN9p

Тагове:
0
C++ Advanced 30/05/2021 09:07:37
Andyzl avatar Andyzl 17 Точки

Привет колега!
По точка 1: Когато използваш getline не си преминал на следващия ред за четене от конзолата. Трябва след като си използвал cin да напишеш std::cin.ignore()
 

1
j.petrov_90 avatar j.petrov_90 332 Точки

Супер сте!

Keep up the good work!

1