JAVA编程---------------31、将一个数组逆序输出

 1 package FushiExam;
 2 import java.util.*;
 3 public class Text_31 {
 4 
 5     public static void main(String[] args) {
 6         // 将一个数组逆序输出
 7         Scanner scan=new Scanner(System.in);
 8         System.out.println("输入你要输入的数组个数:");
 9         int n=scan.nextInt();
10         System.out.println("输入数组:");
11         int[] arr=new int[n];
12         for(int i=0;i<n;i++) {
13             arr[i]=scan.nextInt();
14         }
15         System.out.println("逆序输出:");
16         for(int i=n;i>0;i--) {
17             System.out.print(arr[i-1]+" ");
18         }
19         
20 
21     }
22 
23 }

猜你喜欢

转载自www.cnblogs.com/fmust/p/12515854.html
今日推荐