Pagini recente » Combinatorics shortlist | Combinatorics shortlist | Diferente pentru blog/cpp11 intre reviziile 52 si 47 | Monitorul de evaluare | Diferente pentru blog/cpp11 intre reviziile 43 si 42
Diferente pentru
blog/cpp11 intre reviziile
#43 si
#42
Nu exista diferente intre titluri.
Diferente intre continut:
vector<int> a = {5, 3, 1, 3};
vector<int> b = {6, 1, 7, 2};
vector<int> ind = {0, 1, 2, 3};
sort(ind.begin(), ind.end(), [&a, &b](int x, int y) -> bool {
return a[x] < a[y] || (a[x] == a[y] && b[x] < b[y]);
});
for (int i: ind) {
cout << a[i] << " " << b[i] << endl;
}
==
(Often, a cleaner alternative to using lambda functions for sorting is to define a class holding all the data for each entry and to implement the $<$ operator.)
_Please let us know in the comments section what other $C++11$ features do you use for programming contests. Code snippets illustrating your favorite tricks would be beneficial for us all._
(Often, a cleaner alternative to using lambda functions for sorting is to define a class holding all the data for each entry and to implement the $<$ operator.)
Nu exista diferente intre securitate.
Topicul de forum nu a fost schimbat.