// T1 http://acm.swust.edu.cn/oj/problem/860/.
// Analyze T1
// The linked list is useless because it is a small number of operations.
# Include <stdio. h>
# Include <string. h>
// Char str [105], cmd [6], ch [6];
// The cmd uses an array because "END" is required for receiving, and the input format of % c receives '\ n'
// The ch array is used because '\ n' is received in the input format of % c'
// 3, 6, or 1
Char str [105], cmd [3], ch [1];
Int main ()
{
Int I, j, k, l;
// Considering that the question is a multi-group Operation
While (scanf ("% s", str) = 1)
{
While (scanf ("% s", cmd) = 1 & strcmp (cmd, "END ")! = 0)
{
Scanf ("% s", ch );
L = strlen (str );
If (cmd [0] = 'A') // A operation
{
Scanf ("% d", & k );
-- K;
If (k> l) k = l;
//////////////////////////////////////// //////////////////////////////////
// This is a good piece of code with good ideas
// It is suitable for small operations, but it is not good for large operations.
// Move back to make the position of the element to be inserted
// I is the subscript of the last element.
For (I = l-1; I> = k; -- I)
Str [I + 1] = str [I];
//////////////////////////////////////// //////////////////////////////////
Str [k] = ch [0];
Str [++ l] = '\ 0'; // The end ID must be added.
} Else
{// Operation B
//////////////////////////////////////// //////////////////////////////////
// This is an excellent piece of code with excellent ideas
// It is suitable for small operations, but it is not good for large operations.
// The search, deletion, and movement of elements are well handled.
For (I = j = 0; I <l; ++ I)
{
If (str [I]! = Ch [0])
Str [j ++] = str [I];
}
Str [j] = '\ 0 ';
//////////////////////////////////////// //////////////////////////////////
}
}
Puts (str );
}
Return 0;
}