我想问一下,比如:我现在有一个数组a int [] a = new int[]{10,8,9,7,5,1,2,3};我想通过两个数组b和c,去分离这个数组a,
将比4大的值放入数组b中,
将比4小的值放入数组c中,其中b只能是存在比4大的值,
其中c只能是存在比4小的值!!!!!b或c中不能再有其他的数值出现!!!!!我想看看大家的思想是怎么样的????
希望得到大家的帮助!!!!
将比4大的值放入数组b中,
将比4小的值放入数组c中,其中b只能是存在比4大的值,
其中c只能是存在比4小的值!!!!!b或c中不能再有其他的数值出现!!!!!我想看看大家的思想是怎么样的????
希望得到大家的帮助!!!!
对a循环判断,置入List
List转成数组b和c
真的很谢谢!!!我毕竟是新手来的!!!
看来兄弟是一直在线的哦!!!
同时也希望得到别人的帮助!!!!
在此,道一声谢谢了!!!
List c=new ArrayList();
for(int i=0;i<a.length;i++){
if(a[i]>4)b.add(a[i]);
else if(a[i]<4)c.add(a[i]);
}
import java.util.*;
public class testarray
{
public static void main(String[]args)
{
int [] a = new int[]{10,8,9,7,5,1,2,3};
ArrayList c = new ArrayList();
ArrayList b = new ArrayList();
for(int i = 0;i< a.length;i++)
{
if (a[i] >=4)
c.add(a[i]);
else
b.add(a[i]);
}
Integer[]b1 = new Integer[b.size()];
Integer []c1 = new Integer[c.size()];
c.toArray(c1);
b.toArray(b1);
for(int i = 0;i<b1.length;i++)
System.out.println(b1[i]);
for(int i = 0;i<c1.length;i++)
System.out.println(c1[i]);
}
}
谢谢了!!!!
小弟我,真的很想与你做个朋友!!!不为了什么,只为了可以学习与交流!!!
真的很谢谢了!!!
QQ号码:11601684
真的很希望成为wuheng66888(吴恒) 的朋友!!!