ITPub博客

首页 > > > copyEvens

copyEvens

作者:友哥 时间:2017-02-15 21:18:00 0 删除 编辑
public int[] copyEvens(int[] nums, int count) {
  
  int newIndex=0;
  int i=0;
  int newArray[] = new int[count];
  while(newIndex < count ){
    if( ( nums[i] % 2) ==0  ) newArray[newIndex++]=nums[i];
    
    i++;
  }
  
  return newArray;
  
}

http://codingbat.com/prob/p134174

原文作者:;如有侵权,请联系管理员删除。

上一篇: 算法需要加强
请登录后发表评论 登录
全部评论

注册时间:2020-05-20

  • 博文量
    276
  • 访问量
    999