import java.util.Scanner;
public class Array {
private static Scanner sca;
public static void main(String[] args) {
int [] arr={1,2,3,4,5,6,7,8,9,10};
System.out.println("Enter the number of digit you want to put forward:");
int n;
sca = new Scanner(System.in);
n=sca.nextInt();
int len=arr.length;
reverse(arr,0,n-1);
reverse(arr,4,len-1);
reverse(arr,0,len-1);
for(int i=0;i<len;i++)
{
System.out.println(arr[i]);
}
}
public static void reverse(int []arr,int start,int end)
{
/* for(int i=start;i<(start+end);i++)
{
int temp=0;
temp=arr[i];
a
}*/
while(start<=(start+end)/2)
{
int temp;
temp=arr[start];
arr[start]=arr[end];
arr[end]=temp;
start++;
end--;
}
}
}
|