Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

JohnSteel avatar JohnSteel 6 Точки

02. Treasure Hunt

Здравейте, 

Не успявам да си намеря грешката. Полудях от търсене.

Моля за помощ.

https://pastebin.com/XHLWuATJ

 

условието е следното:

Create a program that manages the state of the treasure chest along the way. On the first line, you will receive the initial loot of the treasure chest, which is a string of items separated by a "|".
"{loot1}|{loot2}|{loot3} … {lootn}"
The following lines represent commands until "Yohoho!" which ends the treasure hunt:
"Loot {item1} {item2}…{itemn}":
Pick up treasure loot along the way. Insert the items at the beginning of the chest. 
If an item is already contained, don't insert it.
"Drop {index}":
Remove the loot at the given position and add it at the end of the treasure chest. 
If the index is invalid, skip the command.
"Steal {count}":
Someone steals the last count loot items. If there are fewer items than the given count, remove as much as there are. 
Print the stolen items separated by ", ":
"{item1}, {item2}, {item3} … {itemn}"
In the end, output the average treasure gain, which is the sum of all treasure items length divided by the count of all items inside the chest formatted to the second decimal point:
"Average treasure gain: {averageGain} pirate credits."
If the chest is empty, print the following message:
"Failed treasure hunt."
Input
On the 1st line, you are going to receive the initial treasure chest (loot separated by "|")
On the following lines, until "Yohoho!", you will be receiving commands.
Output
Print the output in the format described above.
Constraints
The loot items will be strings containing any ASCII code.
The indexes will be integers in the range [-200…200]
The count will be an integer in the range [1….100]
 

 

Тагове:
1
C# Fundamentals
krum_43 avatar krum_43 750 Точки

Ето още едно решение на задачата(100/100).

https://pastebin.com/aD95y9VK

0
23/10/2021 09:51:29
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.