#include<iostream> #include<ctime> #include<cstdlib> using namespace std; int random(int n) { return (long long)rand()*rand%n; } int main() { srand(unsigned(time(0))); // //求负数随机数,先产生0-2n之间的随机整数,再减去n就得到了-n - n 之间的数 }