我是否正确嵌套数组?

Blu*_*kis 1 c arrays ascii function cs50

我目前正在练习编写拼字游戏分数计算器,我正在尝试一步一步地构建它,但我被出了什么问题难住了:

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

// Points assigned to each letter of the alphabet
int POINTS[] = {1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10};

int compute_score(string word);

int main(void)
{
    // Get word from player
    string word1 = get_string("Player 1: ");
    
    // Calculate score
    int score1 = compute_score(word1);
    
    // Print score
    printf("%i\n", score1);
}

int compute_score(string word)
{
    // Compute and return score for string
    return POINTS[word[1] - 65];
}
Run Code Online (Sandbox Code Playgroud)

目前我只是想让我的程序运行一个玩家和一个字母来测试compute_score将字母映射到POINTS数组中的分数的功能。我的逻辑POINTS[word[1] - 65]如下:Z例如,如果我输入,word[1]则等于Z。ASCII 中的“Z”为 90;90 - 65 = 25;POINTS[25]10

所以POINTS[word[1] - 65]= POINTS[Z - 65]= POINTS[25]= 10

但是,当我运行该程序时,我收到了 的答案0,所以我一定是搞砸了什么,我是否只是错过了一些非常明显的东西?

任何帮助将不胜感激。

Sim*_*mon 5

word 的第一个字符是word[0],因为 C 中的数组是从 0 开始的。