generated from github/welcome-to-github-and-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vectors
63 lines (62 loc) · 1.17 KB
/
vectors
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
53
54
55
56
57
58
59
60
61
62
63
/*#include<iostream>
#include<conio.h>
using namespace std;
void rotate(int a[],int n){
int i,j,first;
int d;
cout<<"Enter the times of rotation: "<<endl;
cin>>d;
for(i=0;i<d;i++){
first=a[0];
}
for(j=0;j<n-1;j++){
a[j]=a[j+1];
}
a[j]=first;
}
void printArray(int a[], int n){
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
}
int main(){
int a[]={45,47,78,95};
int n=sizeof(a)/sizeof(a[0]);
rotate(a,n);
cout<<"rotated array is : "<<endl;
printArray(a,n);
return 0;
}
*/
#include<iostream>
#include<conio.h>
using namespace std;
int main(){
int i,a[5],g;
int l=sizeof(a)/sizeof(a[0]);
cout<<"Enter the elements of array: "<<endl;
for(i=0;i<l;i++){
cin>>a[i];
}
for(i=0;i<l;i++){
cout<<a[i];
cout<<"\t";
}
cout<<endl;
int n=3,first,j;/*
cout<<"enter the times of rotation: "<<endl;
cin>>"n";*/
for(i=0;i<n;i++){
first=a[0];
for(j=0;j<l-1;j++){
a[j]=a[j+1];
}
a[j]=first;
}
cout<<"array after the rotation is :"<<endl;
for(i=0;i<l;i++){
cout<<a[i];
cout<<"\t";
}
return 0;
}