(程式语言)(精品)

上传人:无*** 文档编号:244224243 上传时间:2024-10-03 格式:PPT 页数:49 大小:448KB
返回 下载 相关 举报
(程式语言)(精品)_第1页
第1页 / 共49页
(程式语言)(精品)_第2页
第2页 / 共49页
(程式语言)(精品)_第3页
第3页 / 共49页
点击查看更多>>
资源描述
*,*,*,按一下以編輯母片標題樣式,按一下以編輯母片,第二層,第三層,第四層,第五層,Programming Language(,程式語言,),Chapter 6,Data Types(,資料型態,),Topics,Introduction,Primitive data types(,基本資料型態,),Character string types(,符號字串型態,),User-defined ordinal types(,使用者定義順序型態,),Array types(,陣列型態,),Associative arrays(,關聯陣列,),Record types(,紀錄型態,),Union types(,聯合型態,),Pointer and reference types(,指標與參考型態,),2,Introduction,Data type defines,A collection of data objects and a set of predefined operations on those objects,一群資料物件與再這物件上被預先定義運算集合,3,Primitive Data Types,Almost all programming languages provide a set of,primitive data types,Primitive data types,Those not defined in terms of other data types,沒有被定義再其他的資料型態中,Some primitive data types are merely(,只是,)reflections(,反映,)of the hardware,Integer type,Others require(,需要,)only a little non-hardware,4,Integer,The most common privative numeric(,數字的,)data type is integer,Javas signed integer sizes,byte,short,int,long,C+and C#include unsigned integer types,Unsigned types are often used for binary data,5,Floating Point,Model real numbers,but only as approximations(,近似值,),Languages for scientific(,科學,)use support at least two floating-point types,Float,and,double,IEEE Floating-Point,Standard 754,6,IEEE Standard 754 Floating-Point,(,單精確度,),(,倍精確度、雙精確度,),7,Decimal(10,進位,),For business applications(money),Essential(,基本,)to COBOL,C#offers a decimal data type,Store a fixed number of decimal digits,Advantage,Accuracy(,準確,),Disadvantages,Limited range(,有限的範圍,),Wastes memory(,消耗記憶體,),8,Boolean,Simplest(,最簡單,)of all,Range of values:two elements,True,False,Could be implemented as bits,but often as bytes,Advantage,Readability,9,Character(,字元,),Stored as numeric(,數值,),codings,Most commonly used coding:ASCII,An alternative,16-bit coding:Unicode,Includes characters from most natural languages,Originally used in Java,C#and JavaScript also support Unicode,10,Character String Types,Values are sequences of characters,Design issues,Should strings be simply a special kind of character array or a primitive type?,Should strings have static or dynamic length?,11,Character String Types Operations,Typical operations,Assignment,and copying,Comparison(=,etc.),Catenation(,串接,),Substring reference(,子字串參考,),Pattern matching(,樣式匹配,),12,Character String Type in Certain Languages,C and C+,Not primitive(,基本,),Use,char,arrays and a library of functions that provide operations,Java,Primitive via the,String,class,13,Character String Length Options,Static,Javas,String,class,Limited dynamic length,C and C+,In C-based language,a special character is used to indicate the end of a strings characters,rather than maintaining(,維持,)the length,Dynamic(no maximum),Perl,JavaScript,Ada supports all three string length options,14,Character String Implementation,Static length,Compile-time descriptor,Limited dynamic length,May need a run-time descriptor for length(but not in C and C+),Dynamic length,Need run-time descriptor;allocation/de-allocation is the biggest implementation problem,15,Compile-and Run-Time Descriptors,Compile-time descriptor for static strings,Run-time descriptor for limited dynamic strings,16,Ordinal Types,An ordinal type is one in which the range of possible values can be easily associated(,組合,)with the set of positive integers(,正整數,),Examples of primitive ordinal types in Java,integer,char,boolean,17,User-Defined Ordinal Types,In some language,users can define two kinds of ordinal type,Enumeration(,列舉,),Subrange,(,子範圍,),18,Enumeration Types,All possible values,which are named(,被命名,)constants(,常數,),are provided in the definition,C#example,enum,days,mon,tue,wed,thu,fri,sat,sun;,Design issues,Are enumeration values coerced(,強制,)to integer?,Any other type coerced to an enumeration type?,19,Subrange Types,An ordered contiguous(,連續,)subsequence of an ordinal type,Example:12.18 is a subrange of integer type,Pascal,Ada,Adas design,type Days is(mon,tue,wed,thu,fri,sat,sun);,subtype Weekdays is Days range mon.fri;,subtype Index is Integer range 1.100;,Day1:Days;,Day2:Weekday;,Day2:=Day1;,20,Implementation of User-Defined Ordinal Types,Enumeration types are implemented as integers,Subrange,types are implemented like the parent types with code inserted(by the compiler)to restrict(,限制,)assignments to,subrange,variables,21,Array Types,An array is a homogeneous(,同質,)aggregate(,集合體,)of data elements(,元素,)in which an individual(,單獨的,)element is identified by its position in the aggregate,relative(,相對,)to the first element,一個陣列是一個同質的資料元素集合體,那個獨立的元素,(,指陣列,),表示集合體的位置,相對於第一個元素,22,Array Indexing,Indexing(or subscripting)is a mapping from indices(,索引,)to elements,array_name(index_value_list),an element,Index Syntax,FORTRAN,PL/I,Ada use parentheses(,圓括號,),(),Most other languages use brackets(,方括號,),23,Arrays Index(Subscript)Types,FORTRAN,C,Java,Integer only,Pascal,Any ordinal type(integer,Boolean,char,enumeration),Ada,Integer or enumeration(includes Boolean and char),C,C+,Perl,and Fortran do not specify,range checking,Java,ML,C#specify range checking,24,Subscript Binding and
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 管理文书 > 施工组织


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!