vector的調試,輸出 字符串組

#include
#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;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章