// Example program
#include <iostream>
#include <string>
#include <cstdlib>
#include <random>
int generate_random_number_offscreen(int screen_size)
{
static std::default_random_engine gen;
static std::uniform_int_distribution<int> dist(0, screen_size-1);
int r = dist(gen);
if (dist(gen)%2 == 0) // pick between left of screen, or right of screen
r -= screen_size; // range[-1000, -1] inclusive
else
r += screen_size; // range[1000, 1999] inclusive
return r;
}
int main()
{
const int screen_size = 1000;
for (int i = 0; i < 10; i++)
{
std::cout << generate_random_number_offscreen(screen_size) << std::endl;
}
}
Ly8gRXhhbXBsZSBwcm9ncmFtCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxyYW5kb20+CgoKaW50IGdlbmVyYXRlX3JhbmRvbV9udW1iZXJfb2Zmc2NyZWVuKGludCBzY3JlZW5fc2l6ZSkKewogICAgc3RhdGljIHN0ZDo6ZGVmYXVsdF9yYW5kb21fZW5naW5lIGdlbjsKICAgIHN0YXRpYyBzdGQ6OnVuaWZvcm1faW50X2Rpc3RyaWJ1dGlvbjxpbnQ+IGRpc3QoMCwgc2NyZWVuX3NpemUtMSk7CiAgCiAgICBpbnQgciA9IGRpc3QoZ2VuKTsKICAgIGlmIChkaXN0KGdlbiklMiA9PSAwKSAvLyBwaWNrIGJldHdlZW4gbGVmdCBvZiBzY3JlZW4sIG9yIHJpZ2h0IG9mIHNjcmVlbgogICAgICAgIHIgLT0gc2NyZWVuX3NpemU7IC8vIHJhbmdlWy0xMDAwLCAtMV0gaW5jbHVzaXZlCiAgICBlbHNlCiAgICAgICAgciArPSBzY3JlZW5fc2l6ZTsgLy8gcmFuZ2VbMTAwMCwgMTk5OV0gaW5jbHVzaXZlCgogICAgcmV0dXJuIHI7Cn0KCmludCBtYWluKCkKewogICAgY29uc3QgaW50IHNjcmVlbl9zaXplID0gMTAwMDsKICAgIAogICAgZm9yIChpbnQgaSA9IDA7IGkgPCAxMDsgaSsrKQogICAgewogICAgICAgIHN0ZDo6Y291dCA8PCBnZW5lcmF0ZV9yYW5kb21fbnVtYmVyX29mZnNjcmVlbihzY3JlZW5fc2l6ZSkgPDwgc3RkOjplbmRsOwogICAgfQp9Cg==