logo

Crowdly

Dans le code suivant, quels sont les bons commentaires ? <First>, <Second>, etc....

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

Dans le code suivant, quels sont les bons commentaires ? <First>, <Second>, etc. ne font pas partie du code et ne servent qu'à identifier les commentaires pour cette question.

#include "user-id.h"

#include <iostream>

#include <regex>

#include <string>

#include <array>

// <First> Version 1.0 - Initial implementation by Hoang

// <Second> The pattern used here is specifically designed to match the structure of a valid email address according to the standards defined by the Internet Engineering Task Force (IETF), with the pattern accounting for a combination of alphanumeric characters, dots, underscores, percent signs, plus signs, and hyphens before the '@' symbol, followed by a domain name, and ending with a period and a top-level domain of at least two characters in length. This ensures that only valid email addresses in this format will be accepted.

// <Third> WARNING: This method does not check if the domain is reachable; it only checks the format.

bool isValidEmail(const std::string& email) {

    // <Fourth> This regex matches an email address that can contain ". _ % + -"

    // Other symbols are not allowed.

    std::regex email_regex(R"([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA0-9]{2,})");

    // <Fifth> Returns true if the email address matches the regex 

    return std::regex_match(email, email_regex);

}

// <Sixth> Using array instead of vector since the number of IDs is fixed.

array<int, NUMBER_OF_IDS> createUserIds() {   

    std::array<int, NUMBER_OF_IDS> userIds; 

    // <Seventh> Inputs for test purposes

    // for (int i = 0; i < NUMBER_OF_IDS; ++i) { 

    //    userIds[i] = i + 1;

    //}

    // <Eighth> TODO: Finish the implementation with the list of userIds from HR.

    

    // <Ninth> for (int i = 0; i < NUMBER_OF_IDS; ++i) { 

    //    userIds[i] *= 2;

    //}

    return userIds;

}

0%
0%
Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на cours.iut-orsay.fr?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!