#include <iostream>
#include <cstdint>
using namespace std;
// your code here: declare enum class AdcConfig : uint8_t
// with ChannelEnable=1, InterruptEnable=2, DMAEnable=4
enum class AdcConfig : uint8_t{ChannelEnable = 1, InterruptEnable = 2, DMAEnable = 4};
void printConfig(uint8_t cfg) {
// your code here: implement void printConfig(uint8_t cfg)
bool none = true;
if (cfg & static_cast<uint8_t>(AdcConfig::ChannelEnable)) {
cout<<"ChannelEnable ";
none = false;
}
if (cfg & static_cast<uint8_t>(AdcConfig::InterruptEnable)) {
cout<<"InterruptEnable ";
none = false;
}
if (cfg & static_cast<uint8_t>(AdcConfig::DMAEnable)) {
cout<< "DMAEnable ";
none = false;
}
if (none) cout << "None";
}
int main() {
int ch, intr, dma;
cin >> ch >> intr >> dma;
uint8_t cfg = 0;
if (ch) cfg |= static_cast<uint8_t>(AdcConfig::ChannelEnable);
if (intr) cfg |= static_cast<uint8_t>(AdcConfig::InterruptEnable);
if (dma) cfg |= static_cast<uint8_t>(AdcConfig::DMAEnable);
printConfig(cfg);
return 0;
}Input
1 0 1
Expected Output
ChannelEnable DMAEnable