Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iterator>
- #include <iostream>
- unsigned const bounds[] = {170, 350, 520, 720};
- unsigned calc_HQ_sprite_idx(unsigned rating)
- {
- auto const begin = std::begin(bounds);
- auto const end = std::end(bounds);
- auto const it = std::upper_bound(begin, end, rating);
- unsigned const idx = it - begin;
- std::cout << "Rating: " << rating << " = sprite[" << idx << "]\n";
- return idx;
- }
- int main()
- {
- calc_HQ_sprite_idx(0);
- calc_HQ_sprite_idx(1000);
- calc_HQ_sprite_idx(500);
- calc_HQ_sprite_idx(520);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement