我必须使用2个数组做一个拼字游戏得分游戏。第一个数组保存用户输入的单词,第二个数组保存每个字母的值。最后需要一个函数来计算分数。我无法将用户值分配给第二个数组以获得分数并获得该函数的正确代码。c + +使用数组的拼字游戏
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <ctime>
using namespace std;
int scoreCalculator(int total);
char userWord;
int points;
int total=0;
int main()
{
char userWord[11];
for (int i=0; i<11; i++)
{
userWord[i]='\0';
}
cout<<"Enter your word less than 10 letters: "<<endl;
cin>>userWord;
cout<<"Here is the word you inputted: "<<userWord<<endl;
int scrabblePoints[26]={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};
for(int j=0; j<26; j++)
{
userWord[i]
}
cout<<"Here is your score: "<<scoreCalculator(total)<<endl;
}
int scoreCalculator(int total)
{
total+=scrabblePoints[j];
}
这是我到目前为止并在那里停留在
IM和什么是您所遇到的麻烦吗? – NathanOliver
请确保在发布代码时确保代码的缩进和可读性正确。 – crashmstr
请重新考虑你对坏习惯的使用['using namespace std;'](http://stackoverflow.com/q/1452721/1171191)和['endl'](http://chris-sharpe.blogspot.co。英国/ 2016/02 /为什么 - 你 - 不应该使用-stdendl.html)。 – BoBTFish