Kodewick
Empieza a aprender →
Básico←→0 / 60

Corregir el test

#038Básicoint &right, int &wrong4 min

La profesora corrige un test: en answers, true es un acierto y false un fallo. mark devuelve cuántos aciertos y fallos hubo mediante dos referencias, right y wrong. Completa el bucle. Sin preguntas, los dos son 0.

Ejemplos
quiz_result({true, true, false, true})→'3 right, 1 wrong'
quiz_result({})→'0 right, 0 wrong'
La funciónstring quiz_result(const vector<bool> &answers)
main.cpp
#include <string>
#include <vector>
using namespace std;

void mark(const vector<bool> &answers, int &right, int &wrong) {
    right = 0;
    wrong = 0;
    for (bool ok : answers) {
        // tu código aquí: suma 1 a right o a wrong
    }
}

string quiz_result(const vector<bool> &answers) {
    int right = 0, wrong = 0;
    mark(answers, right, wrong);
    return to_string(right) + " right, " + to_string(wrong) + " wrong";
}
Ctrl + Enter también ejecuta
Resultado

Ejecutar prueba los ejemplos. Cuando salgan bien, Enviar.