I wanted to use the lambda function somehow, but it doesn't work, and I don't know why.
vector<int> v;
/* ... */
int median = [](vector<int> a)
{
sort(a.begin(), a.end());
return a[a.size() / 2];
}
I created a lambda function, but how can I call it? int median = [](vector<int> a) { ... } (v)
? But it doesn't work too.
I have seen lambda functions only in some examples like making custom comparator. Can I make it work in my case somehow?
Aucun commentaire:
Enregistrer un commentaire