package Campus; import java.util.Scanner; public class Main{ public static void main(String args[]){ int num = 0; int p = 0; int p_max = 0; int count = 0; Scanner s = new Scanner(System.in);
// hasNext检查序列中是否还有元素,用于循环输入,hasNext()是Scanner类的一个方法,判断是否有输入,有输入项,a .hasNext()为true,没有输入项,a .hasNext()为false。
while(s.hasNext()){
while(s.hasNext()){ num = s.nextInt(); int[] arr = new int[num]; for (int i = 0; i < num; i++){ arr[i] = s.nextInt(); } p = s.nextInt(); p_max = s.nextInt(); // 先判断当前页面是否超过总页数 if (p > num / p_max){ System.out.println("超出分页范围"); }else{ for (int j = p*p_max; j < (p+1) * p_max && j < num; j++){ System.out.println(arr[j]); } } } } }