-
Notifications
You must be signed in to change notification settings - Fork 0
/
13.B.k_LetUsC.c
58 lines (51 loc) · 945 Bytes
/
13.B.k_LetUsC.c
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
#include <stdio.h>
char retrieveL(char [],int );
char retrieveR(char[],int);
char insertL(char[],char);
char insertR(char[],char);
int count(char[]);
int main(){
char r1,r2;
char dequeue[25]={'a','c','d','f'};
insertL(&dequeue[0],'z');
insertR(&dequeue[0],'m');
r1=retrieveL(&dequeue[0],5);
r2=retrieveR(&dequeue[0],5);
printf("%c %c",r1,r2);
return 0;
}
char retrieveL(char j[],int n){
return j[n];
}
char retrieveR(char j[],int n){
int m=count(&j[0]);
return j[m-n];
}
char insertL(char j[],char n){
int m=count(&j[0]),i;
char temp=j[0];
j[0]=n;
for(i=1; i<=m+1; i++){
char k=j[i];
j[i]=temp;
temp=k;
}
return;
}
char insertR(char j[],char n){
int m=count(&j[0]);
j[m+1]=n;
return;
}
int count(char j[]){
int i,fcount=-1;
for(i=0; i<25; i++){
if(j[i]>0){
fcount++;
}
else{
break;
}
}
return fcount;
}