1380 问题 J: Easy List Operations

时间限制: 1s 内存限制: 32MB 提交: 17 解决: 5
题目描述
A list is a sequence of or more elements, expressed in this form: [a 1 , a 2 , a 3 , ... , a n ], where each a i
is or more consecutive digits or lowercase letters. i.e. each list begins with a left square bracket,
then zero or more elements separated by a single comma, followed by a right square bracket. There will
be no whitespace characters (spaces, TABs etc) within a list.
In this problem, we use two list operations: append (++) and remove (--).
1. A ++ B: append elements in B to the end of A.
2. A -- B: remove all the elements in B, from A. If something appears more than once in B, remove it that
many times in A. If there are many equal elements in A to choose from, remove them from left to right
(until all occurrences are removed, or there is no need to remove more elements).
Your task is to write a calculator, evaluating simple expressions or the form "list1 ++ list2" or "list1 --
list2".

输入
There will be at most 10 expressions, one in each line, each having the form "list1 ++ list2" or "list1 --
list2", with no more than 80 characters in total (not counting the newline character). There will be exactly
two spaces in each line: one before and one after the operator. Input ends with a single dot. The input is
guaranteed to satisfy the restrictions stated above.

输出

For each expression, print its result on a single line.

样例输入
[1,2,3] ++ [1,2,3]
[a,b,c,t,d,e,t,x,y,t] -- [t]
[a,b,c,t,d,e,t,x,y,t] -- [t,t,t,t]
[123] ++ [456]
.
样例输出
[1,2,3,1,2,3]
[a,b,c,d,e,t,x,y,t]
[a,b,c,d,e,x,y]
[123,456]
提示

零基础的同学可以先学习基础,教程见:  C语言教程C++教程编译器教程数据结构教程Python教程单片机教程

视频教学见视频网课

比赛公告

题号:1371,1372,1373,1374,1375,1376,1377,1378,1379,1380

点击上方导航栏的训练,点击题库,寻找题号即可找到对应题目,比赛结束后,请通过训练->题库->寻找对应题目的方式做题

因为不确定因素太多,就不再安排大家轮流讲题了,大家做不出题可以在测试结束后去题库找对应的题目看题解,希望大家自觉练习,认真练习,考核测试会采取不同与现在测试的方式,两个月后综合测试成绩不达标者会退出实验室,希望大家认真对待