Pascal语言_文件操作.ppt

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

program area(input,output); const pi=3.1415926; var r:longint; s:real; begin readln(r); s:=pi*r*r; writeln(s:0:4); end. 程序运行时: 执行到read或readln语句, 由键盘输入数据; 执行到write或writeln语句, 内容显示到屏幕上。 program apple; var h:array[1..10]of integer; tao,i,ans:integer; begin for i:=1 to 10 do read(h[i]); readln(tao); ans:=0; for i:=1 to 10 do if tao+30=h[i] then ans:=ans+1; writeln(ans); end. 要求你的程序,保存为apple.pas; 从指定的输入文件(apple.in)中读入数据; 把运行结果输出到指定的输出文件(apple.out)中。 program apple; begin assign(input,’apple.in’); reset(input); assign(output,’apple.out’); rewrite(output); ………….//原有代码 close(input); close(output); end. 执行到read或readln语句时, 从apple.in中读取数据; 执行到write或writeln语句时, 把内容写到apple.out中。 assign(input,’apple.in’); reset(input); 把键盘(input)和文件apple.in建立联系,并打开apple.in文件,后面执行到read或readln语句时,从apple.in中读取数据。 assign(output,’apple.out’); rewrite(output); 把屏幕 (output)和文件apple.out建立联系,并建立apple.out文件,后面执行到write或writeln语句时,内容写到apple.out文件中。 program apple; var h:array[1..10]of integer; tao,i,ans:integer; begin assign(input,apple.in); reset(input); assign(output,apple.out); rewrite(output); for i:=1 to 10 do read(h[i]); readln(tao); ans:=0; for i:=1 to 10 do if tao+30=h[i] then ans:=ans+1; writeln(ans); close(input); close(output); end. apple.pas存盘的默认位置 apple.in也要放在该位置。

文档评论(0)

文档精品 + 关注
实名认证
内容提供者

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

版权声明书
用户编号:6203200221000001

1亿VIP精品文档

相关文档