Monday, February 8, 2016

STL: Vector example, a simple program

#include<vector>
#include<bits/stdc++.h>

using namespace std;

int main()
{
string s[10];
vector<string> name;         //you can use your own data type
vector<string>::iterator i;

for(int j=0; j<10; j++)
{
getline(cin,s[j]);
if(s[j]=="#") break;
name.push_back(s[j]);
}
for(i=name.begin(); i!=name.end(); ++i)
{
cout<<*i<<endl;
}
}

No comments:

Post a Comment

Thank you for commenting. Please wait for response :)