-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathArray_Rotation_c
More file actions
52 lines (46 loc) · 995 Bytes
/
Copy pathArray_Rotation_c
File metadata and controls
52 lines (46 loc) · 995 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
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<stdio.h>
int n,i,j;
int arr[10];
void LeftShift(int *arr)
{
int k=arr[0];
for(j=0;j<n-1;j++)
arr[j]=arr[j+1];
arr[n-1]=k;
for(i=0;i<n;i++)
printf("%d ",arr[i]);
printf("\n");
}
void RightShift(int *arr)
{
int k=arr[n-1];
for(j=n-1;j>=0;j--)
arr[j]=arr[j-1];
arr[0]=k;
for(i=0;i<n;i++)
printf("%d ",arr[i]);
printf("\n");
}
void main()
{
printf("Please enter number of the elements\n");
scanf("%d",&n);
arr[n];
printf("Please enter the elements\n");
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
while(1)
{
printf("Enter the Choice:\n1)for left shift\n2)for right shift\n3)for exit\n");
scanf("%d",&i);
switch(i)
{
case 1:LeftShift(arr);
break;
case 2:RightShift(arr);
break;
case 3:return;
default:printf("No proper input\n");
}
}
}