#include <iostream>
using namespace std;
class HardwareTimer {
private:
int frequency;
bool enabled;
int prescaler;
public:
// Default constructor sets safe reset values
HardwareTimer() : frequency(0), enabled(false), prescaler(1) {}
void configure(int freq, int pre) {
frequency = freq;
prescaler = pre;
enabled = true;
}
void stop() {
enabled = false;
}
void print() {
cout << "F=" << frequency
<< " P=" << prescaler
<< " EN=" << (enabled ? 1 : 0);
}
};
int main() {
HardwareTimer t; // uses default constructor
int f, p, x;
cin >> f >> p >> x;
t.configure(f, p);
if (x == 0)
t.stop();
t.print();
return 0;
}
Explanation & Logic Summary:
configure() activates the timer and sets operating parameters.stop() disables the timer, simulating hardware shutdown behavior.Firmware Relevance & Real-World Context:
Input
1000 8 1
Expected Output
F=1000 P=8 EN=1