かんたん作成【HTML CSS JavaScript PHP CGI Perl Ruby Python .htaccess】

おみくじ(rand)

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

void print_rand(void) {
    char    kuji[][8] = {"大吉", "中吉", "小吉", "吉", "凶", "大凶"};
    int    r;
    srand((unsigned) time(NULL));
    r = rand() % (sizeof(kuji) / sizeof(kuji[0]));
    printf("おみくじ: %s\n", kuji[r]);
}

int main(void) {
    printf("Content-type: text/html\n\n");
    printf("<html>\n");
    printf("<head>\n");
    printf("<title>おみくじ</title>\n");
    printf("</head>\n");
    printf("<body>\n");
    print_rand();
    printf("</body>\n");
    printf("</html>\n");
    return 0;
}
かんたん作成【HTML CSS JavaScript PHP CGI Perl Ruby Python .htaccess】