Brauche Hilfe bei einer C++ Aufgabe.



  • Badestrand schrieb:

    Sollte es hier inline char random_char() { return std::rand() % ('a' - 'z') + 'a'; } nicht 'z'-'a' heißen statt andersrum?

    Auszug aus dem Standard:

    "... If both operands are nonnegative then the remainder is nonnegative; if not, the sign of the remainder is implementation-defined..."

    Ich würde sagen wenn man es venünftig machen will, ist 'z'-'a' die eindeutig bessere Wahl. 🙂


Anmelden zum Antworten