01. Modify Numbers
Здравейте, колеги някой може ли да види къде греша , по условието всичко се изпълнява а в judge 83 / 100 .
1.Modify Numbers
You are given an array with integers separated by a single space. Write a program to modify the array elements after processing a sequence of commands "swap", "multiply", "decrease", "increase" or "remove" until you receive the command "end". The commands are as follows:
- "swap <index1> <index2>" - takes two elements and swaps them.
- "multiply <index1> <index2>" - takes element at the 1st index and multiplies it with the element at 2nd index. Save the product at the 1st index.
- "decrease <number>" - decreases all elements in the array with the number.
- "increase <number>" - increases all elements in the array with the number.
- "remove <index>" - remove the element.
Examples
Input |
Output |
23 -2 321 87 42 90 -123 swap 1 3 swap 3 6 swap 1 0 multiply 1 2 multiply 2 1 decrease 1 end |
86, 7382, 2369942, -124, 41, 89, -3 |
Comments |
|
23 -2 321 87 42 90 -123 – initial values swap 1(-2) and 3(87) -> 23 87 321 -2 42 90 -123 swap 3(-2) and 6(-123) -> 23 87 321 -123 42 90 -2 swap 1(87) and 0(23) -> 87 23 321 -123 42 90 -2 multiply 1(23) 2(321) = 7383 -> 87 7383 321 -123 42 290 -2 multiply 2(321) 1(7383) = 2369943 -> 87 7383 2369943 -123 42 90 -2 decrease – all – 1 -> 86 7383 2369942 -124 41 89 -3 |
Input |
Output |
2 8 -5 88 -57 122 6 48223 increase 5 remove 2 remove 6 end |
7, 13, 93, -52, 127, 11 |
Много ти благодаря стана 100/100