欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

问题 6,问题,public class

来源: javaer 分享于  点击 13734 次 点评:45

问题 6,问题,public class


public class Prob6{      public static void main(String[] argsv){         int start = new Integer(argsv[0]).intValue();         int end = new Integer(argsv[1]).intValue();         System.out.println(difference(start, end));      }      private static long difference(int start, int end){         return squareOfSum(start, end) - sumOfSquares(start, end);      }      private static long squareOfSum(int start, int end){         long result = 0;         while(start <= end){            result += start;            start++;         }         return result * result;      }   // Interval [start, end]      private static long sumOfSquares(int start, int end){         long result = 0;         while(start <= end){            result += start * start;            start++;         }         return result;      }   }
相关栏目:

用户点评