For example: insert 1 5 88 99 7 in a set if 1,5,88,99,7 is given as an input and then pressed Enter. My code:
#include <bits/stdc++.h>
using namespace std;
set <char> num;
set <char> ::iterator i;
int main()
{
int a;
while(a=getchar())
{
if(a!='\n')
{
if(a!=',')
num.insert(a);
}
else
break;
}
for(i=num.begin(); i!=num.end(); i++)
cout<<*i<<endl;
}
The output I'm getting: 1 5 7 8 9