Literaly the second day I've been working on this.
I was given instructions to create a boolean switch program that would accept boolean values as input for a, b, and, c in that order but was told it could only be done using three conditionals and 3 flips. Once it runs, it would execute pseudocode:
- if a is true, flip the value of b
-THEN if b is true, flip the value of c
-THEN if c is true, flip the value of a.
Finally, outputting a, b, and c.
So the input/output would look like this:
>101
<110
or
>100
<011
so far, i have the following
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
using namespace std;
int main() {
cout << "Please enter 1 or 0 for a, b, and c in that order." << endl;
bool a, b, c;
cin >> a >> b >> c;
if (a) {
b = !b;
}
if (b) {
c = !c;
}
if (c) {
a = !a;
}
cout << a << b << c << endl;
|
but the issue im having with is the input. It works perfectly if I input the three values separately instead of on the same line