Computer Scientists are Pretty Pessimistic

Tuesday, 1 March 2016

Use of Set in C++

#include <iostream>
#include <cstdio>
#include <set>
using namespace std;
int main ()
{
    set<int>s;
    int val,i;
    for(i=0;i<10;i++)
    {
        cin>>val;
        s.insert(val);
    }
    set< int > :: iterator it;
    for(it = s.begin(); it != s.end(); it++)
    {
        cout << *it << endl;
    }
    return 0;
}

No comments:

Post a Comment