-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumber68.java
More file actions
39 lines (38 loc) · 783 Bytes
/
Number68.java
File metadata and controls
39 lines (38 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.*;
public class Number68 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n,i,k,j;
System.out.println("Enter the size of the array");
n=sc.nextInt();
int a[]=new int[n];
System.out.println("Enter "+n+" numbers");
for(i=0;i<n;i++)
{
a[i]=sc.nextInt();
}
System.out.println("Enter the specified cutting point");
k=sc.nextInt();
if(k>n||k<0)
System.out.println("Invalid position");
else
{
int b[]=new int[k];
for(i=0;i<k;i++)
{
b[i]=a[i];
}
for(j=0;i<n;i++,j++)
{
a[j]=a[i];
}
for(i=0;j<n;j++,i++)
{
a[j]=b[i];
}
}
System.out.println("The changed array is ");
for(i=0;i<n;i++)
System.out.print(a[i]+" ");
}
}