// Output a random-ish skyline of N buildings. // (The standard "rand" function isn't very random, and filtering its output // using modulo isn't really good enough either. Nonetheless, we can use this // program to quickly create some random skylines over the required range of N // values.) #include #include #include bool read_int(char const * arg, int & v) { std::stringstream ss; ss << arg; ss >> v; return ss; } int main(int argc, char * argv[]) { int errors = 0; int N = -1; srand(time(0)); if (argc != 2 || !read_int(argv[1], N) || N < 0) { ++errors; std::cerr << "Usage: " << argv[0] << " N"; } else { int const W = 1000; int const H = 100000000; std::cout << N << '\n'; while (N-- != 0) { std::cout << rand() % W << ' ' << rand() % H << " "; } std::cout << '\n'; } return errors; }