0
我有這樣的txt數據:列在多維數組C#
跳蚤,0,0,1,0,0,0,0,0,0,1,0,0,6,0, 0,0,6
青蛙,0,0,1,0,0,1,1,1,1,1,0,0,4,0,0,0,5
青蛙, 0,0,1,0,0,1,1,1,1,1,1,0,4,0,0,0,5
我需要計算選定列中零的數量,例如在第一列中有3個零。
這裏是我到目前爲止的代碼:
//data patch
string[] tekst = File.ReadAllLines(@"C:\zoo.txt");
//full of array
string[] tablica = tekst;
for(int s=0;s<tablica.Length;s++)
{
Console.WriteLine(tablica[s]);
}
//----------------Show all of array---------------------------//
//----------------Giv a number of column-----------------////
Console.WriteLine("Podaj kolumne");
int a = Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("Podaj wiersz");
//int b = Convert.ToInt32(Console.ReadLine());
int n = tablica.Length;
int m = tablica[a].Split(',').Length;
string[,] liczby = new string[n, m];
for (int j = 0; j < n; j++)
{
int suma = 0;
for (int i = 0; i < m; i++)
{
//somethink should be here
}
}
解決這個任何想法?
您嘗試過什麼嗎?你有什麼問題? – astidham2003
請將文字視爲文字,而不是圖像。 –
我不知道如何計算這個零,因爲你看到我不知道怎麼把第二個()和txt添加爲文本 – Domi