撰寫程式,讀取10 個整數,然后按照和讀入順序相反的順序將它們顯示出來,
Write a program that reads ten integers and displays
them in the reverse of the order in which they were read.
// https://cn.fankuiba.com
import java.util.Scanner;
public class Ans7_2_page236 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter 10 integers: ");
int[] number = new int[10];
for (int i = 0; i < 10; i++) {
number[i] = input.nextInt();
}
for (int i = 9; i >= 0; i--)
System.out.print(number[i]+" ");
}
}
適用Java語言程式設計與資料結構(基礎篇)(原書第11版)Java語言程式設計(基礎篇)(原書第10/11版)
發布在博客:(https://cn.fankuiba.com)
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/161016.html
標籤:Java
上一篇:超詳細Maven技術應用指南
下一篇:Spring系列.事務管理
