public class ReverseArrayMain {
public static void main(String[] args) {
int [] a={5,6,3,7,4,8,2,9};
ReverseArray ra=new ReverseArray();
BubbleSort bsort=new BubbleSort();
BubbleSort.print(a);//a출력
int [] c=bsort.bbsortinc(a);
int [] b=ra.reverse(a);
BubbleSort.print(c);//a bubble 출력
BubbleSort.print(b);//b reverse
ra.reverseb(c);//c reverse
BubbleSort.print(c);
}
}
class ReverseArray {
public int[] reverse(int [] arr){
int count=arr.length;
int[] a=new int[count];
for(int i=0;i<count;i++){
a[count-i-1]=arr[i];
}
return a;
}
public void reverseb(int [] arr){
int count=arr.length;
for(int i=0;i<=count/2;i++){
int temp=arr[i];
arr[i]=arr[count-i-1];
arr[count-i-1]=temp;
}
}
}
'DEMO CODE > JAVA 기초' 카테고리의 다른 글
[JAVA] Ex010 로또번호 출력하기 (0) | 2015.05.19 |
---|---|
[JAVA] Ex008 BubbleSort - 정렬 (0) | 2015.05.19 |
[JAVA] Ex007 Calendar, Date 정보출력 (0) | 2015.05.19 |
[JAVA] Ex006 다중for문, if 예제 (0) | 2015.05.19 |
[JAVA] Ex005 Math method (0) | 2015.05.19 |