Compile-Time Timer Reload

#include <iostream>
using namespace std;

// Define constexpr computeReload here

constexpr unsigned int computeReload(unsigned int clockHz, unsigned int intervlaMs){
    return (clockHz * intervlaMs + 500)/1000;
};
constexpr unsigned int RELOAD_TABLE[3] = {computeReload(1000000,1), computeReload(1000000,10), computeReload(1000000, 100)};
// Define constexpr RELOAD_TABLE here

int main() {
    int idx;
    cin >> idx;
    cout<< RELOAD_TABLE[idx];
    // Print RELOAD_TABLE[idx]

    return 0;
}

Solving Approach

 

 

 

 

Upvote
Downvote
Loading...

Expected Output

1000