
算法基础
manson7230
这个人很懒,什么也没有留下。
展开
-
算法基础(三)---- 计算字符串数字平均值
给定一个字符串,如"0,11,0,10,33,44,10,98,67,87,98",去除最少的数(可能有多个)和最大的数(可能有多个),然后计算平均值package other;import java.text.DecimalFormat;import java.util.ArrayList;public class test2 { static String str = "原创 2015-09-13 01:11:11 · 3712 阅读 · 0 评论 -
算法基础(二)---- 统计城市个数
List的数据如{"广东", "广州"},{"广西", "桂林"},{"广东", "佛山"},{"广东", "江门"},{"广西", "阳朔"},{"湖北", "荆州"},{"湖南", "长沙"},{"湖北", "襄阳"}......统计每个省的城市个数public class test1 { class CityDTO { private String pro; priva原创 2015-04-24 16:18:18 · 1056 阅读 · 2 评论 -
算法基础(四)---- 计算数组组合最大和
给定一个任意长度的数组,求数组内的数能组合出来的最大整数如数组{9, 98, 123, 32},结果是99832123package other;import java.util.ArrayList;public class Main { public static void main(String args[]) { ArrayList al = new ArrayL原创 2015-09-20 22:20:24 · 1516 阅读 · 0 评论 -
算法基础(五)---- 求第K条线段的长度
给X轴上N个点,这N个点可以组成 N*(N - 1)/ 2 条线,求第K条线段的长度如Points : [0, 1, 3, 5] ,当K = 5时,结果是2package other;public class Main { public static void main(String args[]) { Main main = new Main(); int count =原创 2015-10-11 15:15:22 · 837 阅读 · 0 评论 -
算法基础(一)---- 不使用Integer.parseInt将String转为Int
题目:不使用Integer.parseInt(str)方法,将String类型的整数字符串转为Int类型的整数例如将"-46570"转为-46570,将"146570"转为146570,注意,也不能使用Integer.valueOf(str).intValue();算法一:public class test2 { public static void main(Strin原创 2015-04-24 12:00:31 · 2077 阅读 · 2 评论