HW7.15

HW7.15

 public class Solution
 {
     public static void main(String[] args)
     {
         double[][] set1 = {{1, 1}, {2, 2}, {3, 3}, {4, 4}};
         double[][] set2 = {{0, 1}, {1, 2}, {4, 5}, {5, 6}};
         double[][] set3 = {{0, 1}, {1, 2}, {4, 5}, {4.5, 4}};

         System.out.println(isOnOneLine(set1));
         System.out.println(isOnOneLine(set2));
         System.out.println(isOnOneLine(set3));
     }

     public static boolean isOnOneLine(double[][] array)
     {
         double sub = array[0][1] - array[0][0];
         for(int i = 0; i < array.length; i++)
         {
             if(array[i][1] - array[i][0] != sub)
                 return false;
         }
         return true;
     }
 }
上一篇:eclipse中如何向开源中国(码云)上传代码


下一篇:SpringBoot2.0 url中出现特殊符号「带括号{}'"等等」时会抛出400错误