#include #include #include int main() { std::vector grades = {70, 85, 40, 92, 55, 30}; int sum = 0; int count = 0; int threshold = 50; // Δέσμευση με αναφορά (&) για να τροποποιούμε τα sum και count // Δέσμευση με τιμή (threshold) γιατί μόνο το διαβάζουμε std::for_each(grades.begin(), grades.end(), [&sum, &count, threshold](int g) { if (g >= threshold) { sum += g; count++; } }); if (count > 0) { std::cout << "Average of passing grades: " << (double)sum / count << std::endl; // Έξοδος: Average of passing grades: 75.5 } }