Last active
October 3, 2018 09:36
-
-
Save aoloe/5431de9056897d498c639cc179137be2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <cassert> | |
std::string get_alter_typ(int alter) | |
{ | |
std::string typ{}; // typ definiert | |
if (alter < 18) // alter vergleichen | |
{ | |
typ = "jung"; // typ setzen | |
} | |
else | |
{ | |
typ = "alt"; | |
} | |
return typ; // typ zurückgeben | |
} | |
int main() | |
{ | |
std::string typ_01 = get_alter_typ(12); | |
assert(typ_01 == "jung"); // sicherstellen, das 12 gibt jung | |
std::string typ_02 = get_alter_typ(19); | |
assert(typ_02 == "alt"); // sicherstellen, das 12 gibt jung | |
int alter{0}; | |
std::cout << "Alter? "; | |
std::cin >> alter; | |
std::cout << get_alter_typ(alter) << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment