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 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM