39 lines
678 B
C++
39 lines
678 B
C++
#include <iostream>
|
|
#include <string>
|
|
|
|
// typ funkcji: int -> bool
|
|
// dodany argument wywołania
|
|
|
|
|
|
bool login(std::string secretPassword){
|
|
std::string usersPassword;
|
|
|
|
for(int i=0;i<3;i++){
|
|
std::cout << "Podaj hasło: ";
|
|
std::cin >> usersPassword;
|
|
|
|
if(usersPassword != secretPassword){
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
}
|
|
|
|
int main(){
|
|
const std::string currentPassword = "tajne_haslo";
|
|
|
|
bool result = login(currentPassword);
|
|
|
|
if(result){
|
|
std::cout << "Zalogowano pomyślnie" << std::endl;
|
|
}else{
|
|
std::cout << "Trzy razy wpisano błędne hasło" << std::endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|