編寫程序后众,讀取10 個整數(shù)放闺,然后按照和讀入順序相反的順序?qū)⑺鼈冿@示出來祟昭。
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è)計與數(shù)據(jù)結(jié)構(gòu)(基礎(chǔ)篇)(原書第11版)Java語言程序設(shè)計(基礎(chǔ)篇)(原書第10/11版)
發(fā)布在博客:(https://cn.fankuiba.com)