/**
 * 
 */
package Student_System;
import java.util.*;
import java.util.*;
/**Homework11
 *
 *Homework1101
 *已知一个数组,求数组中心元素
 * @author 读你一世
 *  
 * QQ: 1816274408
 *2017年4月11日上午10:25:03
 *
 */
public class Homework1101 {
	
	public static void main(String[] args){
	Scanner scan=new Scanner(System.in);
	System.out.print("请输入你要输入数组的元素个数:");
	int number =scan.nextInt();
	int[] a=new int [number];
	
	System.out.print("请输入你的数组:\n");
	for(int i=0;i<number;i++){
		a[i] =scan.nextInt();
	}
	for(int i=0;i<a.length;i++){
		System.out.print(a[i]+" ");
		
	}
	
		if(a.length%2==0){
			System.out.print("该数组的中心元素为:" +a[a.length/2]+ " 和  " +a[a.length/2+1]);
		}else{
			System.out.print("该数组的中心元素为:" +a[a.length/2]);
		}
	}
	
	}
原文:http://www.cnblogs.com/Jack1816274408/p/6706796.html