Ejemplo n.º 1
0
static GHashTable*
create_hash_from_key_file (const gchar *bmpath)
{
	GKeyFile *kfile;
	GHashTable *hash;

	kfile = g_key_file_new ();

	if (!g_key_file_load_from_file (kfile, bmpath, G_KEY_FILE_NONE, NULL)) {
		g_key_file_free (kfile);
		return NULL;
	}

	hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
	fill_hash (hash, kfile);

	g_key_file_free (kfile);

	return hash;
}
Ejemplo n.º 2
0
int main ()
{
    int i = 0;
    int j = 0;
    int len = 0;
    int hash = 0;
    int n;
    int day = 0;
    int m = 0;
    char month[10];
    int year = 0;
    int day_num = 0;
    int day_name = 0;

    int *haab_number = (int *)malloc(sizeof(int) * hash_bucket);
    for (i = 0; i < hash_bucket; ++i) {
        haab_number[i] = 0;
    }
    fill_hash(haab_number, hash_bucket);

    scanf("%d", &n);
    printf("%d\n", n);
    for (i = 0; i < n; ++i) {
        scanf("%d. %s %d", &day, month, &year);
        len = strlen(month);
        hash = 0;
        for(j = 0; j < len; ++j) {
            hash += month[j] - ('a' - 'A');
        }
        m = haab_number[hash];
        day = year * 365 + (m - 1) * 20 + day;

        year = day / (13 * 20);
        day = day % (13 * 20);
        day_num = day % 13 + 1;
        day_name = day % 20;
        printf("%d %s %d\n", day_num, tzolkin_days[day_name], year);
    }

    return 0;
}