Home > other >  What is a string
What is a string

Time:09-19


~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Development tools and key technology, data structure and algorithm
Author: li yu good
Writing time: on May 28, 2020,
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

String is short for string, in data structures, the string is a kind of data element has a certain constraint conditions of the linear table, which requires all data elements that form the linear table are characters, so is a finite sequences of characters,
String is composed of zero or more characters finite sequence, as s="s0s1... "Sn - 1 n 0 or higher), which s is string name, character number n is called the length of the string, double apostrophe enclosed sequences of characters" s0s1... Sn - 1 "is the list of values, each character can be letters, Numbers, or any other symbols, zero the string of characters (i.e.," ") as an empty string, an empty string does not contain any character, it is worth noting:
(1) the length of 1 blank string "" is not the same as an empty string" ";
(2) the value of a single character string is not the same as a single character, such as "a" and 'a';
(3) string value does not contain double apostrophe, double apostrophe is the string delimiter,
Any consecutive character in the string of sequence called a substring of this string, string contains the substring say that give priority to string, usually called the serial number of characters in a string of the characters in a string of position, the position of the substring in the string of the clock with the substring in the main position of the first character of string, in order to make you a better understanding of substring, give a simple example, such as:
S="I am from Canada.";
S1="am."
S2="am".
S3="I am";
S4="I am".
S5="I am";
S2, s3, s4, s5 is s substring, or s is s2, s3, s4, s5 series, main and s1 is not s substring, s3 is equal to the s5, s2 is not equal to s4, the length of s is 17, the length of the s3 is 4, the length of the s4 is 5,
List of the basic algorithm is widely used in the list of application, the basic algorithm not only deepen the understanding of the string, a more simplified application of string in the future, is introduced through examples below list of commonly used basic algorithm,
Hypothesis has the following series: s1="I am a student", s2="the teacher", s3="student", commonly used series of the basic computing has the following several kinds:
(1) the Assign (s, t), to Assign values of t s,
(2) Assign (s4, s3) or Assign (s4, "student"), s4="student",
(3) Length (s), find the Length of s,
14, (4) Length (s1)=Length (s3)=7,
(5) Equal (s, t), s and t judge whether the Equal,
(6) Equal (s2, s3)=false, Equal (" student ", s3)=true,
(7) the Concat (s, t), connect the t s at the end of such as: Concat (s3, "number")="student number",
(8) Substr (s, I, len), strives for the substring, such as: Substr (s1, 7, 7)="student", Substr (s1, 10, 0)="", Substr (s1, 0, 14)=" I am a student, "
(9) Insert (s, I, t), in the first before I place s Insert string of t, the Insert (s3, 0, "good_"), the s3="good_student",
(10) the Delete (s, I, len), Delete a substring, ss="good_student", Delete (ss, 0, 5), ss="student",
(11) Replace (s, u, v), the substring replacement, the substring in the u s replaced with the string of v, the Replace (s1 and s3 and s2), s1="I am a to the teacher," the Replace (s1, "the worker", s2) after s1 values, if ss="abcbcbc", are: the Replace (ss, "CBC", "x"), the ss="abxbc", Replace (ss, "cb", "z"), the ss="abzzc,"
(12) index (s, t), substring orientation, namely t o substring in the main position in the string s, index (s1 and s3)=7, the index (s1, s2)=1, the index (s1, "I")=0,
  • Related