28 lines
621 B
C
28 lines
621 B
C
|
#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]);
|
||
|
}
|