🚀 Added language selector

This commit is contained in:
Steph 2022-12-01 21:02:00 +01:00
parent 9ff8098f52
commit 6852dafe59
2 changed files with 27 additions and 0 deletions

BIN
2020/random Executable file

Binary file not shown.

27
2020/random.c Normal file
View File

@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void) {
char date_string[11];
time_t tm = time(NULL);
struct tm* local = localtime(&tm);
// Seed the randomizer with the current date
strftime(date_string, sizeof(date_string), "%G %m %d", local);
int sum = 1;
for(int i=0; date_string[i]; i++)
sum = sum * date_string[i];
srand(sum);
// Pick a random item from the list
char* list[] = {
"C", "D", "F#", "Racket", "Pascal",
"PureScript", "Rust", "fish"
};
int length = sizeof(list) / sizeof(list[0]);
int num = rand() % length;
printf("Your lucky language is %s\n", list[num]);
}