-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomework.cpp
More file actions
45 lines (45 loc) · 744 Bytes
/
homework.cpp
File metadata and controls
45 lines (45 loc) · 744 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
void StrReplace_Sq2(DSqString &S,char ch){
int i,j;
for(i=0;i<S.length;i++){
if(S.str[i]==ch){
for(j=i;j<S.length;j++){
S.str[j]=S.str[++j];
}
S.length--;
}
}
}
void StrReplace_L2(SLinkString &S,char ch){
SLinkString p,q;
int i,j;
p=S->next;
while(p){
if(p->next->str==ch){
p->next=p->next->next;
free(p->next);
}
}
}
void StrReplace_Sq(DSqString &S,DSqString &T,int i,int j){
int x,y=0;
if(i<0||j<0||j>S.length||i>S.length)return false;
for(x=i+1;x<j;x++){
S.str[x]=T.str[y++];
}
}
bool Index_Sq(DSqString S,DSqString T){
int i=0,j=0;
int count=0;
while(i<S.length&&j<T.length){
if(S.str[i]==T.str[j]){
if(j=T.length-1){
count++;
}
i++;
j++;
}else{
i=i-j+1;
j=0;
}
}
}