- 1、本文档共16页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
字符和字符串(Characters and strings)
字符和字符串(Characters and strings)
The use of characters and string types
(a) character type
A character, literal, or character variable consisting of a character, defined by a literal constant:
Const
Character constant = character;
Character variable definition:
Var
Character variable: char;
The character type is an ordered type, and the size of the character is ordered in accordance with the size of its ASC II code. Functions succ, PRED, and ord apply to character types, for example:
Successor function: succ (a) = B
Forward continuation function: PRED (B) = A
Serial number function: ord (A) =65
[example 1] print each letter in alphabetical order and reverse order at any other letter:
A, C, e, G, I, K, m, O, Q, s,, u, W, y
Z, x, R, V, t, P, N, l, J, h,, F, D, B
Procedures are as follows:
Program ex8_1;
Var letter:char;
Begin
For letter:=, a, to, Z, do
If (ord (letter) -ord (a)) mod, 2=0, then, write (letter:3);
Writeln;
For letter:=, Z, downto, a, do
If (ord (letter) -ord (Z)) mod 2, =0, then, write (letter:3);
Writeln;
End.
Analysis: in the program, we take advantage of the characteristic that the character type is a sequential type, which directly takes the character type variable as the loop variable, so that the program is handled more intuitively.
(two) string type
A string is a sequence of characters, a string, and a string type definition:
Type string type identifier =string[n];
Var
String variables: string type identifiers;
Where: n is the length of the string must be defined, 0~255 between natural integers, the actual length of storage on the No. zeroth unit, when the program is run by the system automatically provides storage on Unit No. 1~n in character, if written in string[n] string, the default value is 255 n.
For example: type
Man=string[8];
Line=string;
Var
Name:man;
Screenline:line;
Another type of character is defined by merging the variable definitions of type descriptions.
For example: VAR
Name:STRING[8];
Screenline:STRING;
In Turbo Pascal, charact
您可能关注的文档
- 国内外案例__转载(Domestic and foreign cases __ reprint).doc
- 国内企业的人力资源管理挑战(Challenges of human resource management in domestic enterprises).doc
- 国内外零售企业大举扩张 人才难找薪水水涨船高_业界_科技时代_新浪网(Domestic and foreign retail enterprises expand personnel salary rises to find _ industry _ era of science and technology _ sina.com.cn).doc
- 国内外滤波器的发展(Development of filter at home and abroad).doc
- 国内外高分电影及影评(High score films and reviews at home and abroad).doc
- 国外农村养老保障体系建设及其对我国的启示(Construction of rural endowment insurance system in foreign countries and Its Enlightenment to China).doc
- 国内零售市场竞争和主要特点(Domestic retail market competition and key features).doc
- 国学书目书目(Bibliography of Sinology).doc
- 国家职能观 财政职能及财政支出范围的理论选择(The theory of national function view, financial function and financial expenditure range).doc
- 国家语委语料库(American National Corpus).doc
最近下载
- 期末测试卷(试题)-2024-2025学年人教PEP版(2024)英语三年级上册.docx VIP
- 高二年级第一次月考质量分析化学.doc VIP
- 人教部编版小学语文三年级上册期中质量检测试题(答案+评分标准).pdf VIP
- 小红书2023“家生活”趋势白皮书-青年志&安娜&奥维云网-2023-64页.pdf
- 小学生主题班会 垃圾分类(课件).pptx
- 江西省南昌市八年级上学期期中数学试卷附参考答案.pdf VIP
- QC∕T 948-2013 汽车顶部装载装置.pdf
- 2024年浙江事业单位招聘-宁波慈溪市机关事业单位编外招5人考试备考题库及答案解析.docx VIP
- 风险评估及控制管理流程 2023年ISO15189医学实验室管理体系.docx VIP
- 滴灌在园林绿化中的应用及前景.doc VIP
文档评论(0)