This commit is contained in:
2026-06-05 01:28:27 +00:00
parent bdde9bd1ca
commit 67b7ced5ba
19 changed files with 276 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int hash(char *word);
int main(void)
{
char *word= get_string("Word: ");
printf("Hash value: %i\n", hash(word));
}
int hash(char *word)
{
if (word == NULL || strlen(word) == 0)
{
return -1;
}
char c = word[0];
if (isalpha(c))
{
c = toupper(c);
return c -'A';
}
return -1;
}