Test instructions Watashi invented a kind of egg ache (Eggache) language you want to implement an array slicing function for this language function is to have an array initially empty each time you give you an interval [L, R) and some number you want to output the array subscript in [l , r) and then delete these numbers and then insert those numbers to you to the position of the array subscript L.
Check-in simulation has not read test instructions saw Watashi scanf high-end usage of the weak to even scanf will not use the force to CPP preview the first record of those who do not understand the scanf usage it
int main () { int n; printf ("hello%n", &n); printf ("%d\n", n); Output Hello 5 return 0;}
Specifier can be [...], [^ ...] Both of these regular expressions
[...] Reads the characters contained in the parentheses and encounters other characters to end this specifier
int main () { char s[500]; int n; scanf ("%[0-9]%n", S, &n);//%[0-9] Read only digits encountered non-numeric end printf ("%s%d\n", S, N); scanf ("%[ab]%n", S, &n); printf ("%s%d\n", S, N); Input " 12345abc" preceded by three spaces //output 12345 8 AB 2 return 0;}
[^...] Indicates that all characters except the characters in the brackets are read and the characters in parentheses are encountered to end this specifier
Of course, these things sscanf also apply
After the preview of the scanf after the input of the problem is very good processing directly with the list of the splice function on the line
#include <bits/stdc++.h>using namespace Std;char s[5000], *ps;int main () { list<int> A, b; int L, R, N, v; List<int>::iterator it; while (~SCANF ("[%d:%d]%[^\n]", &l, &r, s)) { b.clear (); PS = s; while (SSCANF (PS, "%*[^-0-9]%d%n", &v, &n) > 0) { //filter out non '-' and the number is read into a number of //n records scanf How many characters are read PS = PS + N; Read n characters so go ahead n-bit b.push_back (v); } Advance (it = A.begin (), l); while (L < R) { printf ("%d%s", *it, L < r-1?) ", " : ""); it = a.erase (it); l++; } Puts (""); A.splice (it, b); } return 0;}
Array slicing Time limit: 2 Seconds Memory Limit: 65536 KB
Array slicing is a operation that extracts certain elements from an array and packages them as another array. Now your ' re asked to implements the array slicing operations for a new programming language-- eggache* (pronounce D "Eggache star"). The grammar of array slicing in eggache* is:
[
begin :
end ] =
x1,
x2, ...,
xk, ...
where begin ≤ End is indices indicating the range of slice. Redundant whitespaces should be ignored. For each operation, the original slice should is printed first, then these elements would be replaced with the new elements provided. See sample for more details.
Input
There is only one case for this problem, which contains about lines of array slicing operations. It's guaranteed that all operations is valid and the absolute values of all integers never exceed 100. The array is empty ([]) before the first operation.
Output
The output produced by array slicing operations in the eggache* programming language.
Sample Input
[0:0] = 1 2 3 4 5 6 7 8 9[1:1] = -1[1:1] =[0:8] = 9 8 7 6 5 4 3 2 1[2:8] = 2,-3, 5, 7 [0:9] = 000[0 : 1] = 1, 2, 8[2:2] = 4[0:4] =
Sample Output
1,-1, 2, 3, 4, 5, 6, 77, 6, 5, 4, 3, 29, 8,-2,-3,-5,-7, 1, 8, 901, 2, 4
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.