🚀 Added language selector
This commit is contained in:
parent
9ff8098f52
commit
6852dafe59
BIN
2020/random
Executable file
BIN
2020/random
Executable file
Binary file not shown.
27
2020/random.c
Normal file
27
2020/random.c
Normal 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]);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user