以那种方式能够快速的通过横纵坐标确定费率?

解决方案 »

  1.   


    declare @table table (x int,y int,fvalue numeric(3,2))
    insert into @table
    select 1,1,1.04 union all
    select 1,2,1.20 union all
    select 1,3,2.33 union all
    select 2,1,5.12 union all
    select 2,2,6.01 union all
    select 2,3,7.02 union all
    select 3,1,6.21 union all
    select 3,2,6.90 union all
    select 3,3,7.00select * from @table/*
    x           y           fvalue
    ----------- ----------- ---------------------------------------
    1           1           1.04
    1           2           1.20
    1           3           2.33
    2           1           5.12
    2           2           6.01
    2           3           7.02
    3           1           6.21
    3           2           6.90
    3           3           7.00
    */
      

  2.   

    用数组也行,不过数组的坐标只能用整数,用泛型字典,坐标可以用包括字符串等各种类型    Sub Main()        Dim a As New Dictionary(Of Integer, Double)
            a.Add(1, 1.5)
            a.Add(2, 2.3)        Dim b As New Dictionary(Of Integer, Double)
            b.Add(1, 3.4)
            b.Add(2, 5.3)
            Dim big As New Dictionary(Of Integer, Dictionary(Of Integer, Double))
            big.Add(1, a)
            big.Add(2, b)        Console.WriteLine(big(1)(1))
            Console.WriteLine(big(1)(2))
            Console.WriteLine(big(2)(1))
            Console.WriteLine(big(2)(2))
        End Sub
      

  3.   


    Dictionary<string, float> dic = new Dictionary<string, float>();
                dic.Add("1,1", 1.01F);
                dic.Add("1,2", 1.04F);
                dic.Add("2,1", 2.01F);            Console.WriteLine("输入坐标:");
                string XY = Console.ReadLine().ToString();
                if (dic.ContainsKey(XY))
                    Console.WriteLine("坐标为x:{0},y{1},费率:{2}", XY.Split(',')[0], XY.Split(',')[1], dic[XY]);
                else
                    Console.WriteLine("没有找到该坐标对应的费率");            Console.ReadKey();
      

  4.   

    通过Dictionary泛型类查找比较方便直接
    具体Dictionary使用什么类型要看你的设计的参数是什么样了,查找使用ContainsKey方法