1. 程式人生 > >12.08作業10

12.08作業10

逆序,清零

package javadome3;

import java.util.Arrays;

public class Text111 {

	public static void main(String[] args) {
		int arr[] = new int []{1,2,-1,5,-6};
		System.out.println("原陣列");
		for(int n : arr){
			System.out.print(n+" ");
		}
	System.out.println();
	System.out.println("hou");
		for
(int i = arr.length-1;i >= 0;i--){ int j = 0; if(arr[i] < 0 ){ arr[i] = j ; } System.out.print(arr[i]+" "); } } }