ハイスコアを保存するこのプログラムでは、ユーザーにプレーヤーの名前とハイスコアを1行で入力してもらいます(例:「eric87」)。ユーザーが最後のプレーヤーの名前とスコアを入力した後、入力されたスコアを一度に一覧表示する必要があります。「eric97」のように文字列を分割するときにこれを行う方法がわかりません。助けてくれてありがとう!
const int MAX = 20;
static void Main()
{
string[ ] player = new string[MAX];
int index = 0;
Console.WriteLine("High Scores ");
Console.WriteLine("Enter each player's name followed by his or her high score.");
Console.WriteLine("Press enter without input when finished.");
do {
Console.Write("Player name and score: ", index + 1);
string playerScore = Console.ReadLine();
if (playerScore == "")
break;
string[] splitStrings = playerScore.Split();
string n = splitStrings[0];
string m = splitStrings[1];
} while (index < MAX);
Console.WriteLine("The scores of the player are: ");
Console.WriteLine("player \t Score \t");
// Console.WriteLine(name + " \t" + score);
// scores would appear here like:
// george 67
// wendy 93
// jared 14