题意:字符串a+b or a-b 例:
Sample Input
[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].Sample Output[1,2,3,1,2,3][a,b,c,d,e,t,x,y,t][a,b,c,d,e,x,y][123,456]思路:vector。。。。。。。。
题目链接:
View Code
1 #include2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 10 vector vec;11 vector ::iterator it;12 string str1,str2,op;13 14 void Push(string str1){15 vec.clear();16 string str;17 int len=str1.size();18 for(int i=1;i >str1){62 if(str1==".") break;63 vec.clear();64 cin>>op>>str2;65 Push(str1);66 if(op=="++") Add(str2);67 else Sub(str2);68 it=vec.begin();69 cout<<"[";70 if(it!=vec.end()){71 for(it=vec.begin();it!=vec.end();it++){72 cout<<*it;73 if(it+1!=vec.end()) cout<<",";74 }75 }76 cout<<"]"<