#include
#define error 0 # Define OK 1 # define overflow -2
Typedef int stat;
Typedef struct {char * ch; int layth;} StringType;
Void INITSTR (StringType & S); // Initializing S is an empty string. Void Strassign (StringType & T, Char * Chars); // assigns the value of S to T. The actual parameter of S is a string variable. INT strCompare (StringType S, StringType T); // Compare S and T. If S> T, return value> 0; if S = T, return value = 0; if S // Notice, do not use the "s =" form to assign a value of the StringType type, // and use the STRASSIGN function !!! Void INITSTR (StringType & S) Malloc (sizeof (char)); if (! s.ch) exit (overflow); s.ley = 0;} Void Strassign (StringType & T, StringType S) {char * p; int i; if (t.ch) free (t.ch); for (i = 0, p = S.CH; * P; i, P); if (! i) {t.ch = null; t.length = 0;} else {if (! (t.ch = (char *) Malloc (i * sizeof (char))) EXIT ( Overflow; for (i = 0, p = S.CH; * p; i, p) T.CH [i] = S.CH [i];} T.Length = i;} Int stringType S, StringType T) {INT I; S.LENGTH = Strlength (s); T.Length = Strlength (T); for (i = 0; i Int stringType S) {INT I; char * p; for (i = 0, p = s.ch; * p; i, p); s.ley = i; return s.LENGTH;} StringType Concat (StringType & T, StringType S1, StringType S2) {char * p, * q; INT I, J; IF (T.CH) free (t.1); s1); S1); S2.LENGTH = Strlength (S2); if (! (T.ch = (char *) Malloc (S1.LENGTH S2.LENGTH) * SIZEOF (CHAR)))) EXIT (OVERFLOW); for (i = 0, p = S1.CH; * p; i, p) T.ch [i] = s1.ch [i]; for (j = 0, q = s2.ch; * q; J, Q) T.ch [S1.LENGTH J] = S2.CH [J]; T.LENGTH = S1.LENGTH S2.LENGTH; RETURN T;} StringType Substring (StringType & Sub, StringType S, INT Start, INT LEN) // When 1 <= START <= Strlength (S) and 0 <= LEN <= Strlength (s) - START 1, // Returns S The START is characterized by a substring of the length of Len, otherwise it returns a null string. {S.Length = Strlength (s); INT i; if (start <1 || start> s.ley "|| LEN <0 || LEN> S.LENGTH-START 1) EXIT (ERROR); if (! LEN) {sub.ch = null; sub.length = 0;} else {if (sub.ch) free (sub.ch); sub.ch = (char *) malloc (len * sizeof (char)); if (! Sub.ch) exit (overflow); for (i = 0; i Void Replace (StringType & S, StringType T, StringType V) / * All and String T, Head, Tail, X, Y, Z; INITSTR (StringType T, HEAD, TAIL, X, Y, Z; INITSTR) are displayed in StringType V) / *. T); INITSTR (HEAD); INITSTR (TAIL); INITSTR (X); INITSTR (Y); INITSTR (Z); INT i = 1; // for (INT i = 1; i <= Strlength (s) - Strlength (T) 2; i) While (i <= Strlength (S) -Strlength (T) 1) {Substring (T, S, I, Strlength (T)); cout << T.CH <