因此,對於我的家庭作業,我需要編寫一種類型的程序,該程序在用戶名稱中包含用戶類型,然後記錄他們的分數。然後它需要找到最高分,最低分和平均分,並列出每一個獲得的玩家。組織數組中的值但保持項目「配對在一起」
static void Main()
{
string userInput;
Console.Write("Please enter bowler's first name and then a score then use a comma to seperate plays\nExample: Elliott 200,John 180,Jane 193\nPlease enter values here: ");
userInput = Console.ReadLine();
char[] delimiters = new char[] { ' ', ','};
string[] parts = userInput.Split(delimiters);
for (int i = 0; i < parts.Length; i++)
{
Console.WriteLine(parts[i]);
}
Console.ReadLine();
}//End Main()
正如你可以看到我已經想出如何分裂的投入,但我不知道如何組織他們和它們配對在一起。我一直在網上尋找答案,並聽說過名單,但我從來沒有使用過它們。這甚至可能在數組上?我需要在兩個不同的陣列上執行此操作嗎?
我也試圖分裂成兩個陣列,但是它有一個轉換的問題
string userInput;
const int ZERO = 0;
const int ONE = 1;
const int TEN = 10;
string[] parsedInput = new string[TEN];
string[] name = new string[TEN];
int[] score = new int[TEN];
for (int i = 0; i < TEN; ++i)
{
Console.Write("Please enter bowler's first name and then a score\nExample: Name 200\nPlease enter values here: ", i);
userInput = Console.ReadLine();
parsedInput = userInput.Split();
name = parsedInput[ZERO];
score = int.Parse(parsedInput[ONE]);
}
創建一個類的列表。或花幾個小時瞭解更多關於編程,數據結構等等。 –