1. Exam Points
String manipulation:
String concatenation: concat(str1, str2)Get a substring: substring(str, start, length) (看题目里的函数怎么给的).Get the lengthof a string: len(str)Reverse a string: Ex. abc -> cba- More operations:
refer to procedures given in questions.
2. Knowledge Points
(1) Strings (字符串)
- A
stringis anordered sequence of characters. - Example:
- Annabelle
- 13697665261
- ID Number (身份证号)
- Each character in a string can be located by its
index, whichstarts from 1.
(2) String Manipulation (字符串操作)
String concatenation(字符串连接): joins together two or more strings end-to-end to make a new string.- Example:
-
concat("abc","def") Result: abcdef ``` -
x ← 18 concat("age: ",x) Result: age: 18 ```
-
- Example:
- A
substringispartof an existing string.- Example:
-
Case 1: Substring(str, start, length) name ← "Annabelle" Substring(name, 5, 4) Result: bell Case 2: Substring(str, start, end) name ← "Annabelle" Substring(name, 5, 8) Result: bell ```
-
- Example:
Revserea string.- Example:
-
str1 ← "abcd" str2 ← reverse(str1) str3 ← concat(str1,reverse(str1)) Value of str2: dcba Value of str3: abcddcba ```
-
- Example:
Get the length(number of characters) of a string.- Example:
-
str ← "abcd" length ← len(str) Value of length: 4 ```
-
- Example: