編寫程序,讀取10 個整數(shù),然后按照和讀入順序相反的順序將它們顯示出來。
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語言程序設計與數(shù)據(jù)結構(基礎篇)(原書第11版)Java語言程序設計(基礎篇)(原書第10/11版)
發(fā)布在博客:(https://cn.fankuiba.com)