Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class arg1
- {
- static BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
- public static void main(String args []) throws IOException
- {
- System.out.print("enter size of array: ");
- int x= 0;
- x=Integer.parseInt(in.readLine());
- int c=0;
- c=x%2;
- if (c==0){
- System.out.print("size of array is not a odd number");
- }
- else{
- int [] p= new int [x];
- for(int y=0;y<x;y++)
- {
- System.out.print("enter element for array#"+(y+1)+": ");
- p[y]=Integer.parseInt(in.readLine());
- }
- int o = p.length;
- System.out.println("**********************");
- int t = 0;
- t= o/2;
- System.out.println("median: "+p[t]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment