小编Mur*_*tAy的帖子

c#字典自动打破for循环,

Dictionary<double, Tuple<int,int>> dictionary = new Dictionary<double, Tuple<int,int>>();

for (int i = 0; i < x.Length; i++)
    for (int j = i+1; j < x.Length; j++)
    {
        double weight = Math.Round(Math.Sqrt(Math.Pow((x[i] - x[j]), 2) + Math.Pow((y[i] - y[j]), 2)), 2);
        string edges = i + "-" + j + "-" + weight;
        listBox1.Items.Add(edges);
        Tuple<int, int> tuple = new Tuple<int, int>(i, j);
        dictionary.Add(weight, tuple);
    }

var list = dictionary.Keys.ToList();
list.Sort();

foreach (var key in list)
{
    string a = dictionary[key].Item1 + "--" …
Run Code Online (Sandbox Code Playgroud)

c# dictionary loops for-loop break

0
推荐指数
1
解决办法
105
查看次数

标签 统计

break ×1

c# ×1

dictionary ×1

for-loop ×1

loops ×1