Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

How do I make this faster?

Name: Anonymous 2019-09-10 17:01

#include <time.h>
#include <stdio.h>
#include <stdlib.h>

int myrand(int min, int max) {
int new_value;
static int previous_value;

if(min > max) return 1;

do {
srand(time(NULL));
new_value = rand() % (max - min);
} while(new_value == previous_value);

previous_value = new_value;
return new_value;
}

int main() {
for(register char c = 0; c < 5; c++) {
printf("%c\t", myrand(33, 126));
}

putchar('\n');
return 0;
}

Name: Anonymous 2019-09-11 23:31

>>15
Print five random ints from 33 to 127, tab-separated
this is still basically assembly. you're still telling the computer how instead of what. it's just a step above:

(loop for x = (random 128) unless (< x 33) collect x into numbers
until (>= (length numbers) 5)
finally (return (format t "~{~A~T~}" numbers)))


which is a thin wrapper over primitive operations despite reading like a sentence

"make a game that's a combination of pong and space invaders"
-- that's when programmers have to start sucking cock for a living Edited on 11/09/2019 23:35.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List