#include <iostream>
#include <string>
using namespace std;
// Define available filter modes
enum FilterMode {
NONE,
LOW,
HIGH
};
// Default filter mode is NONE
int readSensor(int raw, FilterMode mode = NONE) {
if (mode == NONE) {
return raw;
}
if (mode == LOW) {
return raw / 2;
}
return raw / 4; // HIGH filter
}
int main() {
int raw, modeFlag;
cin >> raw >> modeFlag;
if (modeFlag == 0) {
cout << readSensor(raw);
} else {
string filterName;
cin >> filterName;
FilterMode filter = (filterName == "LOW") ? LOW : HIGH;
cout << readSensor(raw, filter);
}
return 0;
}
Explanation & Logic Summary
NONE is automatically selected.LOW and HIGH modes apply progressively stronger integer-based smoothing.Firmware Relevance & Real-World Context
Input
100 0
Expected Output
100