vector的调试,输出 字符串组

来源:互联网 发布:抗弯强度计算软件 编辑:程序博客网 时间:2024/06/04 18:28
#include<iostream>
#include<vector>
#include<string>

using   namespace   std;
//using std::iostream;
//using std::string;
//using std::vector;


int main()
{
cout<<"please push in words"<<endl;
string word;
vector<string> jeff;
while(1)   //也可以直接ctrl+d 结束 ,不用if(word=="abc")
{
cin>>word;
if(word=="abc")
break;
jeff.push_back(word);
  }
vector<string>::size_type n;
n=jeff.size();
//int n=jeff.size();     //也可以用直接用int
//cout<<"erro"<<n<<endl;     //在前后插入看是哪里错了,还是挺好用的。
while(n>0)  //n>0也可以,很奇怪
{
cout<<jeff[n-1]<<endl;  //必须-1!
n--;
}
return 0;
}
原创粉丝点击