首页 > 编程语言 > 详细

去掉为0组成新数组

时间:2017-04-04 20:47:02      阅读:194      评论:0      收藏:0      [点我收藏+]
public class Shu2 {

    public static void main(String[] args) {
        int o[]={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5} ;
        int n[]=new int[o.length];
        //开辟新的数组
        int k=0;
        for(int i=0;i<o.length;i++){
            if(o[i]!=0)    {
                n[k]=o[i];
          System.out.print(n[k]+"\t");      
                k++;
              }
            
        }

    }

}

 

去掉为0组成新数组

原文:http://www.cnblogs.com/zyy1130/p/6665959.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!