64,637
社区成员
发帖
与我相关
我的任务
分享
#include "iostream"
#include "string"
#include "list"
#include "vector"
using namespace std;
template<typename iterator>
void print(iterator begin,iterator end)
{
while(begin!=end)
{
cout<<*begin++<<" ";
}
cout<<endl;
}
void main()
{
for (;;)
{
cout<<"输入字符串:"<<endl;
string str;
cin>>str;
vector<char> myvector;
const char* p =str.c_str();
myvector.assign(str.c_str(),str.c_str()+str.size());
print(myvector.begin(),myvector.end());
}
system("pause");
}
#include "iostream"
#include "string"
#include "list"
using namespace std;
template<typename iterator>
void print(iterator begin,iterator end)
{
while(begin!=end)
{
cout<<*begin++<<" ";
}
cout<<endl;
}
void main()
{
for (;;)
{
cout<<"输入字符串:"<<endl;
string str;
cin>>str;
list<char> mylist;
const char* p =str.c_str();
for(int i=0;i<str.size();i++)
mylist.push_back(p[i]);
print(mylist.begin(),mylist.end());
}
system("pause");
}