-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvectorElementsShifting.c
More file actions
45 lines (36 loc) · 865 Bytes
/
vectorElementsShifting.c
File metadata and controls
45 lines (36 loc) · 865 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
/*
* a basing shifting operation on vector arrays example.
* 01.06.2021 nesh@Aydin
*/
#include <stdio.h>
void ordinalValsPushArr(int arr[],int arrSize){
for(int c=0;c<arrSize;c++)
arr[c]=c+1;
}
void printArr(int arr[],int arrSize){
for(int c=0;c<arrSize;c++)
printf("%d\t",
arr[c]);
printf("\n");
}
void vectorElementsShiftingArr(int arr[],int arrSize,int shift){
int tmpArr[arrSize];
for(int b=0;b<kaydirma;b++){
tmpArr[b]=0;
for(int c=1;c<arrSize-b;c++){
tmpArr[b+c]=arr[c-1];
}}
// bastirma(tmpArr,arrSize);
for(int c=0;c<arrSize;c++)
arr[c]=tmpArr[c];
}
int main()
{
int arr[20];
int arrS=(sizeof(arr)/sizeof(int));
ordinalValsPushArr(arr,arrS);
printArr(arr,arrS);
vectorElementsShiftingArr(arr,arrS,6);
printArr(arr,arrS);
return 0;
}