SelectionStructure选择结构.doc

  1. 1、本文档共7页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
SelectionStructure选择结构.doc

PASCAL CH4: Selection Structure using IF and CASE statement/選擇結構的語句-IF 和 CASE CNECLWS-GiP Page:  PAGE 7 PASCAL Chapter 4: Selection Structure 第四課:選擇結構 4.1 Boolean Expression and Relational Operators (布爾表式及關係符) 4.1.1 Boolean Type Data (布爾類數值) It can be either (?variable ) or ( constant ). 它可以是( 變 量 )或( 常 量 )。 It only has two value: 它只有兩個數值: ( TRUE ) or ( FALSE ). User cannot enter Boolean value, but we can display it. 用戶不能輸入布爾數值,但可以將其數值顯示出來。 Here are some example of Boolean Expression: 以下是一些布爾表式的例子: Example 例子1 program BooleanExample; var checked, answer : boolean;? variable declaration變量說明 const Monday = true;,? constant declaration常量說明 failed = false; begin checked := false;? variable assignment變量賦值 answer := true; ... end. Example例子(Filename檔案名稱: greater.pas)Output display 輸出顯示Program GreaterTest; var A, B : integer; greater : boolean; begin write(Enter the smaller number: ); readln(A); write(Enter the larger number: ); readln(B); greater := AB; writeln(It is: , greater); readln end.Case情況1 Enter the smaller number: 3? Enter the larger number: 9? It is: TRUE Case情況2 Enter the smaller number: 7? Enter the larger number: 2? It is: FALSEThe above expression can be simplified to: 以下表式可以化簡為: greater := AB; writeln(It is: , greater); ?writeln(It is: , AB); 4.1.2 Relational Operators關係運算符 There are six relational operators in PASCAL programming: PASCAL有以下六種關係運算符: Mathematical Operator 數學運算符PASCAL operator 運算符Meaning 意義==Equal to / 等於Greater than / 大於Less than / 小於?=Greater than or equal to / 大於或等於?=Less than or equal to / 小於或等於?Not equal to/ 不等於 The two expression must be in same type, only exception is ( integer ) can compare with ( real ) number. (example 5) 兩類數據一定要有相同類型,唯一例外是( 整 數 )可以與( 實 數 )比較。(例子5) The comparison can also have mathematical expression. (example 6) 比較可以包括算術表式。(例子 6) We can compare character and string. The result are according to the order of ASCII code. (example 7~11) 字符或字符

文档评论(0)

170****0532 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8015033021000003

1亿VIP精品文档

相关文档