import java.util.*;
public class Ch3Q9
{public static void main(String[] args)
{Scanner kbd = new Scanner(System.in);
System.out.print("Enter n: ");
int n = kbd.nextInt();
int [] x = new int [n];
System.out.println("Enter elements: ");
for(int i = 0; i < n; i++)
x[i] = kbd.nextInt();
for(int i = 0; i < n/2; i++)
{int temp = x[i];
x[i] = x[n-i-1];
x[n-i-1] = temp;
}
System.out.println("Enter array is: ");
for(int i = 0; i < n; i++)
System.out.print(x[i]+" ");
}
}
No comments:
Post a Comment