Skip to content

Instantly share code, notes, and snippets.

@aoisensi
Created September 20, 2012 05:12
Show Gist options
  • Save aoisensi/3754078 to your computer and use it in GitHub Desktop.
Save aoisensi/3754078 to your computer and use it in GitHub Desktop.
ujm test 2012/09/20
#include <random>
#include <iostream>
#include <time.h>
using namespace std;
void randomize()
{
srand((unsigned int)clock());
}
int rnd(int o)
{
return (int)(rand()*o/(RAND_MAX+1.0));
}
int* rndarray(int size, int o)
{
int* result = new int[size];
for(int i=0;i<size;++i)
{
result[i] = rnd(o);
}
return result;
}
int main()
{
randomize();
int size = 0;
int o = 0;
while(cin >> size >> o)
{
int* r = rndarray(size, o);
for(int i=0;i<size;++i)
{
cout << r[i] << endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment