Welcome to Westonci.ca, your ultimate destination for finding answers to a wide range of questions from experts. Discover precise answers to your questions from a wide range of experts on our user-friendly Q&A platform. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform.
Sagot :
#include
using namespace std;
int main() {
// Set up 3 groups of responders
int group1Button = 0;
int group1Light = 0;
int group2Button = 0;
int group2Light = 0;
int group3Button = 0;
int group3Light = 0;
// Keep running until someone presses a button
while(group1Button == 0 && group2Button == 0 && group3Button == 0) {
// Check if group 1 presses button
if(group1Button == 1) {
// Turn on group 1 light
group1Light = 1;
// Don't turn on other lights
group2Light = 0;
group3Light = 0;
// First responder, don't wait for buttons
break;
}
// Check if group 2 presses button
if(group2Button == 1) {
// Turn on group 2 light
group2Light = 1;
// Don't turn on other lights
group1Light = 0;
group3Light = 0;
// First responder, don't wait for buttons
break;
}
// Check group 3 button
if(group3Button == 1) {
// Turn on group 3 light
group3Light = 1;
// Don't turn on other lights
group1Light = 0;
group2Light = 0;
// First responder, don't wait for buttons
break;
}
}
// Print out lights
cout << "Group 1 light: " << group1Light << endl;
cout << "Group 2 light: " << group2Light << endl;
cout << "Group 3 light: " << group3Light << endl;
return 0;
}
using namespace std;
int main() {
// Set up 3 groups of responders
int group1Button = 0;
int group1Light = 0;
int group2Button = 0;
int group2Light = 0;
int group3Button = 0;
int group3Light = 0;
// Keep running until someone presses a button
while(group1Button == 0 && group2Button == 0 && group3Button == 0) {
// Check if group 1 presses button
if(group1Button == 1) {
// Turn on group 1 light
group1Light = 1;
// Don't turn on other lights
group2Light = 0;
group3Light = 0;
// First responder, don't wait for buttons
break;
}
// Check if group 2 presses button
if(group2Button == 1) {
// Turn on group 2 light
group2Light = 1;
// Don't turn on other lights
group1Light = 0;
group3Light = 0;
// First responder, don't wait for buttons
break;
}
// Check group 3 button
if(group3Button == 1) {
// Turn on group 3 light
group3Light = 1;
// Don't turn on other lights
group1Light = 0;
group2Light = 0;
// First responder, don't wait for buttons
break;
}
}
// Print out lights
cout << "Group 1 light: " << group1Light << endl;
cout << "Group 2 light: " << group2Light << endl;
cout << "Group 3 light: " << group3Light << endl;
return 0;
}
Thank you for trusting us with your questions. We're here to help you find accurate answers quickly and efficiently. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Westonci.ca is committed to providing accurate answers. Come back soon for more trustworthy information.