{"id":37,"date":"2006-11-13T09:29:05","date_gmt":"2006-11-13T01:29:05","guid":{"rendered":"http:\/\/www.mdrink.cn\/mxx\/?p=53"},"modified":"2006-11-13T09:29:05","modified_gmt":"2006-11-13T01:29:05","slug":"pascal%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"http:\/\/maxiaoxuan.com\/?p=37","title":{"rendered":"Pascal\u5b57\u7b26\u4e32\u51fd\u6570"},"content":{"rendered":"<p><strong>\u6c42\u957f\u5ea6length<\/strong><\/p>\n<p>\u5b9a\u4e49\uff1afunction Length(S: String): Integer;<\/p>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<p>var<\/p>\n<p>S:  String;<\/p>\n<p>begin<\/p>\n<p>Readln (S);<\/p>\n<p>Writeln(\u2018&#8221;\u2018, S, \u2018&#8221;\u2018);<\/p>\n<p>Writeln(\u2018length = \u2018,  Length(S));<\/p>\n<p>end.<\/p>\n<p><strong>\u590d\u5236\u5b50\u4e32copy<\/strong><\/p>\n<p>\u5b9a\u4e49\uff1a function Copy(S: String;  Index: Integer; Count: Integer): String;<\/p>\n<p>\u6ce8\u610f\uff1aS  \u662f\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u8868\u8fbe\u5f0f\u3002Index\u548cCount\u662f\u6574\u578b\u8868\u8fbe\u5f0f\u3002Copy \u8fd4\u56deS\u4e2d\u4eceIndex\u5f00\u59cb\uff0cCount\u4e2a\u5b57\u7b26\u957f\u7684\u4e00\u4e2a\u5b50\u4e32\u3002<\/p>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<p>var S:  String;<\/p>\n<p>begin<\/p>\n<p>S := \u2018ABCDEF\u2018;<\/p>\n<p>S := Copy(S, 2, 3); { \u2018BCD\u2018  }<\/p>\n<p>end.<\/p>\n<p><strong>\u63d2\u5165\u5b50\u4e32insert<\/strong><\/p>\n<p>\u5b9a\u4e49\uff1aprocedure Insert(Source: String;  var S: String; Index: Integer);<\/p>\n<p>\u6ce8\u610f\uff1aSource \u662f\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u8868\u8fbe\u5f0f\u3002 S  \u662f\u4efb\u610f\u957f\u5ea6\u5b57\u7b26\u4e32\u7c7b\u578b\u53d8\u91cf\u3002Index \u662f\u6574\u578b\u8868\u8fbe\u5f0f\u3002Insert \u628a  Source\u63d2\u5728S\u4e2dIndex\u5904\u3002\u5982\u679c\u7ed3\u679c\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u5927\u4e8e255\uff0c\u90a3\u4e48255\u4e4b\u540e\u7684\u5b57\u7b26\u5c06\u88ab\u5220\u9664\u3002<\/p>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<p>var<\/p>\n<p>S:  String;<\/p>\n<p>begin<\/p>\n<p>S := \u2018Honest Lincoln\u2018;<\/p>\n<p>Insert(\u2018Abe \u2018, S, 8); { \u2018Honest  Abe Lincoln\u2018 }<\/p>\n<p>end.<\/p>\n<p>\n<strong>\u5220\u9664\u5b50\u4e32delete<\/strong><\/p>\n<p>\u5b9a\u4e49\uff1aprocedure Delete(var  S: String; Index: Integer; Count:Integer);<\/p>\n<p>\u6ce8\u610f\uff1aS \u662f\u5b57\u7b26\u4e32\u7c7b\u578b\u53d8\u91cf\u3002  Index\u548cCountare\u662f\u6574\u578b\u8868\u8fbe\u5f0f\u3002Delete  \u5220\u9664S\u4e2d\u4eceIndex\u5f00\u59cb\u7684Count\u4e2a\u5b57\u7b26\u3002\u5982\u679cIndex\u5927\u4e8eS\u7684\u957f\u5ea6\uff0c\u5219\u4e0d\u5220\u9664\u4efb\u4f55\u5b57\u7b26\uff1b\u5982\u679cCount\u5927\u4e8eS\u4e2d\u4eceIndex\u5f00\u59cb\u7684\u5b9e\u9645\u5b57\u7b26\u6570\uff0c\u5219\u5220\u9664\u5b9e\u9645\u7684\u5b57\u7b26\u6570\u3002<\/p>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<p>var<\/p>\n<p>s:  string;<\/p>\n<p>begin<\/p>\n<p>s := \u2018Honest Abe Lincoln\u2018;<\/p>\n<p>Delete(s,8,4);<\/p>\n<p>Writeln(s);  { \u2018Honest Lincoln\u2018 }<\/p>\n<p>Delete(s,9,10);<\/p>\n<p>Writeln(s); { \u2018Honest L\u2018  }<\/p>\n<p>end.<\/p>\n<p><strong>\u5b57\u7b26\u4e32\u8f6c\u4e3a\u6570\u503cval<\/strong><\/p>\n<p>\u5b9a\u4e49\uff1a procedure Val(S; var V; var Code:  Integer);<\/p>\n<p>\u5728\u8fd9\u91cc:<\/p>\n<p>S \u662f\u7531\u4e00\u7cfb\u5217\u6570\u5b57\u5b57\u7b26\u6784\u6210\u7684\u5b57\u7b26\u4e32\u7c7b\u578b\u53d8\u91cf\uff1b\u3002<\/p>\n<p>V \u662f\u6574\u578b\u6216\u5b9e\u578b\u53d8\u91cf\uff1b<\/p>\n<p>Code  \u662fInteger\u578b\u53d8\u91cf<\/p>\n<p>\u6ce8\u610f\uff1aVal\u5c06S\u8f6c\u4e3a\u5b83\u7684\u6570\u503c\u5f62\u5f0f\u3002<\/p>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<p>var s:string;I, Code:  Integer;<\/p>\n<p>begin<\/p>\n<p>s:=\u20181234\u2018;<\/p>\n<p>val(s,i,code);<\/p>\n<p>writeln(i); { 1234  }<\/p>\n<p>end.<\/p>\n<p><strong>\u6570\u503c\u8f6c\u4e3a\u5b57\u7b26\u4e32str<\/strong><\/p>\n<p>\u5b9a\u4e49\uff1a procedure Str(X [: Width [:  Decimals ]]; var S:string);<\/p>\n<p>\u6ce8\u610f\uff1a\u5c06\u6570\u503cX\u8f6c\u6210\u5b57\u7b26\u4e32\u5f62\u5f0f\u3002<\/p>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<p>var<\/p>\n<p>S:  string[11];<\/p>\n<p>begin<\/p>\n<p>Str(I, S);<\/p>\n<p>IntToStr :=  S;<\/p>\n<p>end;<\/p>\n<p>begin<\/p>\n<p>Writeln(IntToStr(-5322));<\/p>\n<p>Readln;<\/p>\n<p>end.<\/p>\n<p>\n<strong>\u6c42\u5b50\u4e32\u8d77\u59cb\u4f4d\u7f6epos<\/strong><\/p>\n<p>\u5b9a\u4e49\uff1afunct<span>ion  Pos(Substr: String; S: String):  Byte;<\/span><\/p>\n<p>\u6ce8\u610f\uff1aSubstr\u548cS\u5b57\u7b26\u4e32\u7c7b\u578b\u8868\u8fbe\u5f0f\u3002Pos\u5728S\u4e2d\u641c\u7d22Substr\u5e76\u8fd4\u56de\u4e00\u4e2ainteger\u503c\u3002\u8fd9\u4e2a\u503c\u662fSubstr\u7684\u7b2c\u4e00\u4e2a\u5b57\u7b26\u5728S\u4e2d\u7684\u4f4d\u7f6e\u3002\u5982\u679c\u5728S\u4e2d\u6ca1\u6709\u627e\u5230Substr\uff0c\u5219Pos\u8fd4\u56de0\u3002<\/p>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<p>var  S: String;<\/p>\n<p>begin<\/p>\n<p>S := \u2018 123.5\u2018;<\/p>\n<p>{ Convert spaces to zeroes }<\/p>\n<p>while  Pos(\u2018 \u2018, S) &gt; 0 do<\/p>\n<p>S[Pos(\u2018 \u2018, S)] :=  \u20180\u2018;<\/p>\n<p>end.<\/p>\n<p><strong>\u5b57\u7b26\u5b8c\u5168\u4e32\u8fde+<\/strong><\/p>\n<p>\u5b9a\u4e49\uff1a\u64cd\u4f5c\u7b26+\u628a\u4e24\u4e2a\u5b57\u7b26\u4e32\u8054\u5728\u4e00\u8d77\u3002<\/p>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<p>var  s1,s2,s:string;<\/p>\n<p>begin<\/p>\n<p>s1:=\u2018Turbo \u2018;<\/p>\n<p>s2:=\u2018pascal\u2018;<\/p>\n<p>s:=s1+s2; { \u2018Turbo  pascal\u2018 }<\/p>\n<p>end.<\/p>\n<p><strong>\u5b57\u7b26\u4e32\u538b\u7f29\u7a7a\u683c\u4e32\u8fde-<\/strong><\/p>\n<p>\u5b9a\u4e49\uff1a\u64cd\u4f5c\u7b26-\u53bb\u6389\u7b2c\u4e00\u4e2a\u5b57\u7b26\u4e32\u6700\u540e\u7684\u7a7a\u683c\u540e\uff0c\u5c06\u4e24\u4e2a\u5b57\u7b26\u4e32\u8054\u5728\u4e00\u8d77\u3002<\/p>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<p>var  s1,s2,s:string;<\/p>\n<p>begin<\/p>\n<p>s1:=\u2018Turbo \u2018;<\/p>\n<p>s2:=\u2018pascal\u2018;<\/p>\n<p>s:=s1-s2; {  \u2018Turbopascal\u2018 }<\/p>\n<p>end.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6c42\u957f\u5ea6length \u5b9a\u4e49\uff1afunction Length(S: String): Integer; \u4f8b\u5b50\uff1a v &hellip; <a href=\"http:\/\/maxiaoxuan.com\/?p=37\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Pascal\u5b57\u7b26\u4e32\u51fd\u6570<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[80,85],"class_list":["post-37","post","type-post","status-publish","format-standard","hentry","category-computer","tag-oi","tag-pascal"],"_links":{"self":[{"href":"http:\/\/maxiaoxuan.com\/index.php?rest_route=\/wp\/v2\/posts\/37","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/maxiaoxuan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/maxiaoxuan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/maxiaoxuan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/maxiaoxuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=37"}],"version-history":[{"count":0,"href":"http:\/\/maxiaoxuan.com\/index.php?rest_route=\/wp\/v2\/posts\/37\/revisions"}],"wp:attachment":[{"href":"http:\/\/maxiaoxuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/maxiaoxuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/maxiaoxuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}