37 lines
893 B
C++
37 lines
893 B
C++
#include <iostream>
|
|
using namespace std;
|
|
|
|
int main(){
|
|
string input="";
|
|
bool yOrN;
|
|
|
|
// && "and", returns true if left and right are true
|
|
// || "or", returns true if left or right are true
|
|
// ! "not", ! true = false, ! false = true
|
|
// ! (a || b) <--> !a && !b
|
|
// Haskell: or $ map (==input) ["Yes,"No","y","n"]
|
|
/* while(! (input == "Yes" || input == "y" || input == "No" || input == "n")){
|
|
cout << "Enter an option (Yes/y/No/n): ";
|
|
cin >> input;
|
|
}
|
|
*/
|
|
while(input != "Yes" && input != "y" && input != "No" && input != "n"){
|
|
cout << "Enter an option (Yes/y/No/n): ";
|
|
cin >> input;
|
|
}
|
|
|
|
/*
|
|
if(input == "Yes" || input == "y"){
|
|
yOrN = true;
|
|
}
|
|
else{
|
|
yOrN = false;
|
|
}
|
|
*/
|
|
yOrN = (input == "Yes" || input == "y");
|
|
// will print 1 if yOrN = true
|
|
// will print 0 if yOrN = false
|
|
cout << "Testing our boolean: " << yOrN << endl;
|
|
|
|
return 0;
|
|
} |