在这个存储高分的程序中,我希望用户在一行中输入球员的姓名和高分,例如“eric 87”。在用户输入最后一名球员的姓名和分数后,它应该立即列出所有输入的分数。在拆分像“eric 97”这样的字符串时,我不知道该怎么做。非常感谢您的帮助!
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