Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A random number generator.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
const int MOD = 10;
int main() {
freopen("test.txt", "w", stdout);
srand((int)time(0));
int T = 1000;
cout << T << endl;
for (int i = 0; i < T; ++i) {
int n = rand()%MOD + 5;
cout << n << endl;
for (int j = 0; j < n; ++j)
cout << rand()%MOD - 5 << " ";
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment