P1:输出十以内的所有奇数
P2:计算逆波兰式(字符串,+, -, * 或/)(操作符或是数字之间均用空格隔开)
P3:逆序输出数组的元素
ret[i] = array[array.length-i-1];
P4:利用级数计算PI [4 * ( 1 - 1/3 + 1/5 - 1/7 +......)]
P5:判断数组中是否存在重复的元素
// 双For循环
for (int i=0;i < nums.length - 1;i ++){
for (int j= i+1;j < nums.length;j ++){
if (nums[i]==nums[j])
return true;
}
}
// 哈希表/Set
Set<Integer> set = new HashSet<>();
for (int a:nums)
set.add(a);
if (set.size()<nums.length)
return true;
P6:实现一个日期小工具,要求完成DateUtil.java里的方法
参见java.util.Date
参考用法:
https://www.cnblogs.com/blackheartinsunshine/p/6019408.html
https://blog.csdn.net/hbcui1984/article/details/1331771
P7:在一个int型数组中,1<=a[i]<=n(n是数组长度),有些元素出现了两次,有些出现了一次。找出所有[1,n]中没有出现过的元素
Set+ArrayList
P8:求出对应整数数组中的最大值
P9:给定一个int数组, 包含成绩,成绩大于0,请返回平均成绩。如果成绩大于100,请返回 -1。
P10:从"grades.in"文件中读取n个成绩(成绩为整形,在0-100之间,包括边界值),然后打印直方图
文件格式如下:
numStduents:int
grade1:int grade2:int .... gradeN:int
直方图输出格式如下:
output:
0 - 9:***
10 - 19:***
20 - 29:
30 - 39:
40 - 49:*
50 - 59:*****
60 - 69:
70 - 79:
80 - 89:*
90 -100:**
(Bug待解决)
-------------------------------------------
关于取整Math.round()方法
System.out.println(Math.round(-13.500000));
System.out.println(Math.round(-13.500001));
System.out.println(Math.round(13.499999));
System.out.println(Math.round(13.500000));
输出:
-13
-14
13
14
-------------------------------------------
区分Integer.getInteger和Integer.valueOf、Integer.parseInt() 的使用方法
https://blog.csdn.net/nosxcy/article/details/6989633-------------------------------------------
读写文件:
http://www.cnblogs.com/lovebread/archive/2009/11/23/1609122.html
-------------------------------------------
Assert用法:
https://www.cnblogs.com/wardensky/p/4307848.html