标签:style blog color get 算法 for
List<Point> list = Arrays.asList(new Point(1, 5), new Point(2, 3), new Point(2, 8), new Point(9, 13)); int sum = list.get(0).y - list.get(0).x,currenty=list.get(0).y; Point pnext; for (int i = 1, len = list.size(); i < len; i++) { pnext = list.get(i); if (currenty >= pnext.y) continue; sum += currenty >= pnext.x ? pnext.y - currenty : pnext.y - pnext.x; currenty = pnext.y; } System.out.println(sum);
标签:style blog color get 算法 for
原文地址:http://www.cnblogs.com/anrainie/p/3797068.html