Browse Source

add gaussian fake random value

master
tTh 3 years ago
parent
commit
94f95655c1
2 changed files with 20 additions and 6 deletions
  1. +5
    -3
      fake-values.c
  2. +15
    -3
      funcs.c

+ 5
- 3
fake-values.c View File

@ -14,12 +14,14 @@ int verbosity;
int main(int argc, char *argv[])
{
int opt;
int opt;
int type = 0;
while ((opt = getopt(argc, argv, "vs")) != -1) {
while ((opt = getopt(argc, argv, "vst:")) != -1) {
switch (opt) {
case 'v': verbosity++; break;
case 's': srand(getpid()); break;
case 't': type = atoi(optarg); break;
default: break;
}
}
@ -29,7 +31,7 @@ if (verbosity > 1) {
}
printf("%f %d\n", dtime(), random1000(0));
printf("%f %d\n", dtime(), random1000(type));
return 0;
}


+ 15
- 3
funcs.c View File

@ -12,12 +12,24 @@ extern int verbosity;
/* --------------------------------------------------------------- */
int random1000(int foo)
int random1000(int type)
{
int value;
if (verbosity)
fprintf(stderr, ">>> %s(%d)\n", __func__, foo);
value = rand() % 1000;
fprintf(stderr, ">>> %s(%d)\n", __func__, type);
switch (type) {
case 0:
value = rand() % 1000;
break;
case 1:
value = (rand()%1000 + rand()%1000) / 2;
break;
default:
value = -1;
break;
}
return value;
}


Loading…
Cancel
Save