mardi 9 novembre 2021

How to insert values in set directly from input stream?

How to Insert input directly into set container from input stream?

This is how I need

while(n--)
{
    cin>>s.emplace();
}

Assume,I need to get n inputs and set container name is 's'

while(n--)
{
    int x;
    cin>>x;
    s.emplace(x);
}

This works fine but I need to cut this step.

Aucun commentaire:

Enregistrer un commentaire