我的数组的每个部分都有6位数据显示在这里
83 0 0 -1 0 50
83 0 0 -1 0 50
85 0 0 -1 0 50
87 0 0 -1 0 50
89 0 0 -1 0 50
我需要将每个解析成一个新数组,这样我就可以继续查找平均数等等。 第一列是心率,第二列是速度,是10的幂,所以需要在某种十进制我想浮点。欢呼任何帮助
这是我到目前为止所得到的
int[] hrDataList = new int[5];
string[] seperator = { "\t" };
for (int i = 0; i < hrDataList.Length; i++)
{
string[] temp = hrDataList[i].ToString().Split(seperator, StringSplitOptions.None);
heartrate[i] = int.Parse(temp[0]);
speed[i] = int.Parse(temp[1]);
cad[i] = int.Parse(temp[2]);
alt[i] = int.Parse(temp[3]);
pwr[i] = int.Parse(temp[4]);
pwrbal[i] = int.Parse(temp[5]);
}
答案 0 :(得分:0)
尝试这样的事情:
int[] thearray = new int[5];
int[][] thenewarray = new int[5][];
string[] seperator = { "\t" };
for (int i = 0; i < thearray.Length; i++)
{
string[] temp = thearray[i].ToString().Split(seperator, StringSplitOptions.None);
int[] toadd = new int[temp.Length];
thenewarray[i] = new int[temp.Length];
for (int j = 0; j < temp.Length; j++)
{
thenewarray[i][j] = int.Parse(temp[j]);
}
}
经过测试和工作。