public class TEST { public static void main(String[] args) { int [] oldArr= {1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5}; int [] newArr= new int[oldArr.length] ; int n=0; for (int i=0;i<oldArr.length;i++) { if(oldArr[i]==0) {} else { newArr[n]=oldArr[i]; n++; }
转自:http://blog.csdn.net/laozhaokun/article/details/37531247 题目:有两个有序数组a,b,现需要将其合并成一个新的有序数组. 简单的思路就是先放到一个新的数组中,再排序.但是这样的没体现任何算法,这里考的不是快速排序等排序算法.关键应该是如何利用有序已知这个条件.可以这样想,假设两个源数组的长度不一样,那么假设其中短的数组用完了,即全部放入到新数组中去了,那么长数组中剩下的那一段就可以直接拿来放入到新数组中去了. public class
problom : 'f1' value hava been changed when output. reason : the binary repersentation of 2.2f is : 00110011001100110011... (is an infinite recurring decimal) but computer only store 24 byte , so discard the remaining number , lead to the value has b