比如有格网点x=[1 1 1 1 1
             2 2 2 2 2
             3 3 3 3 3
             4 4 4 4 4
             5 5 5 5 5]
      格网点y=[1 1 1 1 1
             2 2 2 2 2
             3 3 3 3 3
             4 4 4 4 4
             5 5 5 5 5]
      现在我有个点(x=1.2,y=2.3),想求出该点在那个小格网中?

解决方案 »

  1.   

    试试            int[] arr = { 1, 2, 3, 4, 5, 
                              6, 7, 8, 9, 10, 
                              11, 12, 13, 14, 15 };
                double x = 2.3;
                int Split = 5;
                int resultX = (int)x;
                int resultY = (int)(x * 10 % 10);
                int result = resultX * Split + resultY - 1;
                Console.WriteLine(arr[result]);