Loading...

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

Dimov79 avatar Dimov79 6 Точки

Last Stop from Mid Exam April

Здравейте, 

получавам 70/100 точки. Предполагам, че проблема е в Change

 

https://pastebin.com/bLKGpYbj

 

https://judge.softuni.bg/Contests/Practice/Index/1494#2

 

Last Stop

The group has reached Paris and went to visit "La Louvre". They accidently found a map behind "The Wedding at Canna" painting. It had some instructions, so they have decided to follow them and see where they will lead them. Your job is to help them.

Create a program that follows instructions in order to hafulfil a quest. First, you will receive a collection of numbers – each representing a painting number. After that, you are going to be receiving instructions, until the "END" command is given.

  • Change {paintingNumber} {changedNumber} – find the painting with the first number in the collection (if it exists) and change its number with the second number – {changedNumber}.

  • Hide {paintingNumber} – find the painting with this value and if it exists and hide it (remove it).

  • Switch {paintingNumber} {paintingNumber2} – find the given paintings in the collections if they exist and switch their places.

  • Insert {place} {paintingNumber}insert the painting (paintingNumber) on the next place after the given one, if it exists.

  • Reverse – you must reverse the order of the paintings.

Once you complete the instructions, print the numbers of the paintings on a single line, split by a space.

Input / Constraints

  • On the 1st line, you are going to receive the numbers of the paintings, split by a single space – integer numbers in the range [1…1000]

  • On the next lines, you are going to receive commands, until you receive the "END" command

Output

  • Print the message you have received after the conversion of all numbers on a single line

Examples

Input

Output

Comments

115 115 101 114 73 111 116 75

Insert 5 114

Switch 116 73

Hide 75

Reverse

Change 73 70

Insert 10 85

END

70 114 111 116 114 101 115 115

The first command is "Insert". You have to insert painting number 114 at the next index after the 5th:

115 115 101 114 73 111 114 116 75

The "Switch" will switch number 116 with 73 and the collection should look like this:

115 115 101 114 116 111 114 73  75

After receiving the"Hide" command, you must remove 75. After that you receive "Reverse" and you have to reverse the whole collection. By receiving "Change" you have to exchange the value 73 with the value – 70. The next "Insert"command is invalid, because there is no 11th index in the collection.

77 120 115 101 101 97 78 88 112 111 108 101 111 110

Insert 5 32

Switch 97 78

Hide 88

Change 120 117

END

77 117 115 101 101 78 32 97 112 111 108 101 111 110

 

 

Тагове:
0
Module: Java Advanced
hm6566 avatar hm6566 52 Точки
Best Answer

Пасам

numbersPainting.set(indexOne, valueTwo);
numbersPainting.set(indexTwo, valueOne);

 

Пишеш доста добре. Убеден съм, че и сам можеш да си намираш пропуските, ако отделяш малко повече време за това.

 

Успех утре!

0
01/11/2019 22:33:26
Dimov79 avatar Dimov79 6 Точки

Благодаря ти много за отговора и комплимента. За първи път се занимавам с програмиране и все още има много детайли, които не знам и понякога по няколко часа се опитвам да намеря решение на дадена задача поради нещо малко, което не знам. Малките детайли изграждат цялата картина :)

Успех и на теб! 

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