Beispiel #1
0
int main()
{
    int sum = 42;
    int result;
    char str[200];

    scanf("%s", str);

    result = long_hash(str);

    sum = sum + result;

    printf("%d", sum);
    return 0;
}
Beispiel #2
0
int main()
{
    struct occurance_t array_of_occurance[3000];
    int  hash, lenght = 0,  index, j;
    
    char *word;

    while(1)
    {
        word  = (char*) malloc(sizeof(word));
        scanf("%s", word);
        hash = long_hash(word);
        index = get_occurance_t(array_of_occurance, lenght, hash);
        if(index == -1)
        {
            array_of_occurance[lenght].count = 1;
            array_of_occurance[lenght].hash = hash;
            array_of_occurance[lenght].words[0] = word;
            array_of_occurance[lenght].len = 1;
            lenght++;
        }
        else
        {

            int hasWord = 0;
            int i;
            for(i = 0; i < array_of_occurance[index].len; i++)
            {
                if(strcmp(array_of_occurance[index].words[i], word) == 0)
                {
                    hasWord = 1;
                    break;
                }
            }

            if(hasWord == 0)
            {
                array_of_occurance[index].words[array_of_occurance[index].len] = word;
                array_of_occurance[index].len++;
                array_of_occurance[index].count++;
            }

            if(array_of_occurance[index].count == 4)
            {
                sort_strings(array_of_occurance, lenght);

                for(i = 0; i < lenght; i++)
                {
                    if(array_of_occurance[i].count > 1)
                    {
                        printf("%d ", array_of_occurance[i].hash);
                        for(j = 0; j < array_of_occurance[i].len; j++)
                        {

                            printf("%s ", array_of_occurance[i].words[j]);
                        }
                        printf("\n");
                    }

                }
                return 0;
            }
        }
    }



    return 0;
}