Monday, February 8, 2016

STL: Set example, a simple program

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

using namespace std;

int main()
{
string s[50];
set<string>myset;
set<string>::iterator i;


int k;
for(k=0; k<50; k++)
{
getline(cin,s[k]);
if(s[k]=="#") break;
}

for(int i =0 ;i<50; i++)
{
myset.insert(s[i]);
}

for(i=myset.begin(); i!=myset.end(); ++i)
{
cout<<*i<<endl;
}

return 0;
}

No comments:

Post a Comment

Thank you for commenting. Please wait for response :)