c#---读文件

来源:互联网 发布:淘宝上隐形文胸哪种好 编辑:程序博客网 时间:2024/06/06 20:42
 weight = new int[N, N]; //加权矩阵 string[] lines = System.IO.File.ReadAllLines(@"F:\1.txt"); int i = 0; char c = ' '; foreach (string line in lines) //按行读取为字符串数组 {       string[] arr = line.Split(c);       for(int j=0; j<arr.Length; j++)       {             int w = int.Parse(arr[j]);   //字符串转数字             weight[i, j] =  w;       }       i++; }
0 0
原创粉丝点击