1.string转vector
#include#include#include#includeusing namespace std;int main(){
string str = "hello world!";
vector<uint8_t> vec;
vec.assign(str.begin(), str.end());
for(size_t i=0; i<vec.size(); i++){
cout<<vec[i]<<" ";
cout<<endl;
return 0;}
2.vector转string
#include#include#include#includeusing namespace std;int main(){
string str;
vector<char> vec={'a','a','a','b','a'};
str.assign(vec.begin(), vec.end());
cout<<str<<endl;
// vector转 string
string str2;
vector<string> vec2{"hhh", "zzz"};
str2 = accumulate(vec2.begin(), vec2.end(), str2);
cout<<"str2 = "<<str2<<endl;
return 0;}
JAVA栈模板类 java栈api
栈 java.util;Stack 类表示后进先出(LIFO)对象堆栈。 它使用五个操作扩展了类Vector,这些操作允许将向量视为堆栈。Stack<Integer> stack = new Stack<>(); //新建堆栈
stack.push(1) ; // 向stack栈顶压入一个元素
stack.pop() ; // 从stack