右键——默认值——默认代码页——更改为‘437 (OEM - 美国)’——确定
其他的调试步骤:
例1 1的调试:
1、Free Pascal程序的启动
双击桌面上的Free Pascal,启动后,界面如下:
2、第一次启动free pascal 时,用鼠标单击菜单不起作用,需用要进行设置。右击标题栏,选择属性:
3、在属性窗口中,去掉2个快速编辑模式和插入模式前的复选框的勾,再单击确定按纽,新d出:将属性应用于快捷的设置,在该面板中选择:修改启动该窗口的快捷方式。设置好了,关闭free pascal窗口。再重新单击桌面上的free pascal,这时就可以用鼠标来 *** 作了。
4、新建一程序文件:单击菜单File,选择new
5、输入代码,这里的writeln是writeLn,大小写不要紧。Writeln()后面接的是一对括号。
6、保存。按F2,或单击file/save,d出一保存窗口。将文件保存为ex11pas。该文件存储在free pascal的安装目录下:C:\FPC\204\bin\i386-win32
7、编译运行,按Ctrl+F9,编译后,再Alt+F5查看屏幕输出结果。
例12调试:
1、新建一程序文件:单击菜单File,选择new
2、以书本例12为例,在新建的窗口中输入如下代码:
3、代码写完后,单击file / save (或按F2),保存文件,存储为ex12pas,该文件存储在free pascal的安装目录下:C:\FPC\204\bin\i386-win32
4、编译程序。按Ctrl+F9,d出如下窗口:
在此窗口中输入a的值,比如输入5,输完后,敲回车键,回到程序窗口,再按Alt+F5,在屏幕上查看输出结果。
得到输出的结果值,再按回车健Enter,回到主程序界面。
var
j,h:integer;//这步我就不说了
begin
for j:=1 to 5 do//开始循环,次数5次。打印5行
begin
write('':16-j);//在循环的同时把空格打出来,为留下空间
for h:=i to 2j-1 do//从1-1,1-3,1-5,1-7,1-9循环打印
write('');
writeln;//每打印一行就换行。
end
end
输出:
这是一个简单的图形问题。算法就是,先用控制场宽留空间,这一步是利用变量做的。第二步是打印“”,因为此前已经控制了场宽,所以只要按数量打出就行了。
下边是我写的 没测试过 有错的估计就是少个什么标点吧。。
(1)
读入然后输出就行 用length(s)函数 求最大长度
var
s:string;
i:longint;
begin
readln(s);
for i:=length(s)-1 downto 1 do
write(s[i]);
writeln;
end;
(2) val(s,a,b):是指将字符串S转变成a,变量b用一个无用变量就行 我不知道干什么的 但是我知道没什么用
var
s:string;
i,b,c:longint;
a:array[09] of longint;
begin
readln(s);
for i:=1 to length(s) do
begin
val(s[i],b,c);
inc(a[b]);
end;
for i:=0 to 9 do
write(i,':',a[i]);
writeln;
end
(3) 这个题用while来实现 知道找到第一个是‘A’的位置 和第二个是‘A’的位置 进而找出中间字符的个数和字符
var
s:string;
t,f,i:longint;
begin
readln(s);
t:=1;
while s[t]<>'A' do
inc(t);
inc(t);
f:=t;
while s[t]<>'A' do
inc(t);
t:=t-1;
writeln(f-t+1);
for i:=f to t do
write(s[i],' ');
end
(4)第四题看不明白 是题目产生?即 输入数据产生? 还是自己产生。。那输出什么东西。。
很简单,在记事本里写完程序以后,把名字改成 pas (指的是程序名)然后。。把这个文件用鼠标左键拖拽到桌面上Free Pascal的快捷方式里,然后Free Pascal就把程序打开了。--------------------------------------(以上是废话)---------------------------------------------紧接着,在FREE PASCAL标题的正下方,有“ File Edit Search Run Compile ……………… ”点击Compile,然后点击第一个就编译了。。当然,最简单的方法是按下键盘上的ALT键,然后按F9就OK了。
程序运行时占用的内存空间太大,超出了评测时的限制
例如你定义了一个长度为1亿,基类型为integer的一维数组,那么它占用的内存空间就是2亿字节,就是190多MB,很可能会超出限制
具体可以参考一下pascal中的变量各种类型占用的储存空间大小
主要是计算类的。
可以综合各种算法,数据结构,从而写出程序解决某一个或某一类问题,优势就是比人算得快。
经常应用的例如:模拟计算推理过程,解决最优化问题,应该还可以有Dos的功能,例如计算时间,链接路径等,因为Pascal本来就是在Dos的基础上发展来的(不过这方面很少用)。
所以说Pascal程序主要是计算程序,不过可以应用到生活中,比如我就用Pascal程序处理过大量的公司数据,还写过一个求一元高次方程的解的程序,可以辅助解决现实生活中的问题。但是如果LZ是想做一些软件的话,就用Delphi或者干脆改学c++吧
const zm:array[126]of char=('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
var s,t,w,i,s1,j:longint;
a,c:array[026]of char;
begin
assign(input,'e4in');reset(input);
assign(output,'e4out');rewrite(output);
readln(s,t,w);
for i:=1 to w do read(c[i]);
a:=c;
repeat
i:=w+1;
repeat
dec(i);
until ((a[i]>=zm[s])and(a[i]<zm[t]))or(i<=0);
if i=0 then begin
close(input);
close(output);
halt;
end;
a[i]:=succ(a[i]);
for j:=i+1 to w do
a[j]:=succ(a[j-1]);
if a[w]<=zm[t] then
begin
for j:=1 to w do
write(a[j]);
writeln;
s1:=s1+1;
end;
until s1>=5;
close(input);close(output);
end
标程,希望能帮到你!
var pan:array[016,016] of string;
i,j,h1,h2,l1,l2,h,l,n,n1,n2,choose,z1,z2:integer;
ju1,ju2:array[010000] of string;
s1,s2,p1,p2:string;
hui1,hui2:boolean;
procedure juout;
begin
for i:=1 to z1 do
writeln(ju1[i],ju2[i]);
writeln('1 保存棋局');
writeln('2 退出');
read(choose);
case choose of
1:begin
assign(output,'五子棋棋局txt');
rewrite(output);
for i:=1 to z1 do
writeln(ju1[i],ju2[i]);
close(output);
exit;
end;
2:exit;
end;
end;
procedure options;
begin
writeln('双方悔棋次数限定:');
writeln('(初始值为0)');
read(n);
n1:=n;
n2:=n;
end;
procedure out;
begin
write(' ');
for i:=1 to 15 do
write(i:2);
writeln;
for i:=1 to 15 do
begin
write(i:2);
for j:=1 to 15 do
write(pan[i,j]);
writeln;
end;
end;
function trytry1(h,l:integer):boolean;
var i,t:integer;
begin
trytry1:=false;
t:=0;
i:=0;
while pan[h-i,l]='○' do begin inc(i); inc(t); end;
i:=0;
while pan[h+i,l]='○' do begin inc(i); inc(t); end;
if t>=6 then begin trytry1:=true; exit; end;
t:=0;
i:=0;
while pan[h,l-i]='○' do begin inc(i); inc(t); end;
i:=0;
while pan[h,l+i]='○' do begin inc(i); inc(t); end;
if t>=6 then begin trytry1:=true; exit; end;
t:=0;
i:=0;
while pan[h-i,l-i]='○' do begin inc(i); inc(t); end;
i:=0;
while pan[h+i,l+i]='○' do begin inc(i); inc(t); end;
if t>=6 then begin trytry1:=true; exit; end;
t:=0;
i:=0;
while pan[h-i,l+i]='○' do begin inc(i); inc(t); end;
i:=0;
while pan[h+i,l-i]='○' do begin inc(i); inc(t); end;
if t>=6 then begin trytry1:=true; exit; end;
end;
function trytry2(h,l:integer):boolean;
var i,t:integer;
begin
trytry2:=false;
t:=0;
i:=0;
while pan[h-i,l]='●' do begin inc(i); inc(t); end;
i:=0;
while pan[h+i,l]='●' do begin inc(i); inc(t); end;
if t>=6 then begin trytry2:=true; exit; end;
t:=0;
i:=0;
while pan[h,l-i]='●' do begin inc(i); inc(t); end;
i:=0;
while pan[h,l+i]='●' do begin inc(i); inc(t); end;
if t>=6 then begin trytry2:=true; exit; end;
t:=0;
i:=0;
while pan[h-i,l-i]='●' do begin inc(i); inc(t); end;
i:=0;
while pan[h+i,l+i]='●' do begin inc(i); inc(t); end;
if t>=6 then begin trytry2:=true; exit; end;
t:=0;
i:=0;
while pan[h-i,l+i]='●' do begin inc(i); inc(t); end;
i:=0;
while pan[h+i,l-i]='●' do begin inc(i); inc(t); end;
if t>=6 then begin trytry2:=true; exit; end;
end;
procedure game;
begin
repeat
inc(z1);
read(h,l);
while (h=0) and(l=0) and(hui1=false) do
begin
writeln('对不起,双方不能连续悔棋');
read(h1,l1);
h:=h1;l:=l1;
while (pan[h1,l1]='○') or (pan[h1,l1]='●') or (h1<1) or (h1>15) or(l1<1) or (l1>15) do
begin
writeln('对不起 该处不能落子');
writeln('黑棋走子 请输入落子坐标');
read(h1,l1);
h:=h1;l:=l1;
end;
end;
while (h=0) and(l=0) and(n1=0) do
begin
writeln('对不起,您的悔棋机会已用完');
writeln('黑棋走子 请输入落子坐标');
readln(h,l);
while (pan[h,l]='○')or(pan[h,l]='●')or((h=0) and (l<>0))or((l=0) and (h<>0))or(h1<0)or(h1>15)or(l1<0)or(l1>15) do
begin
writeln('对不起 该处不能落子');
writeln('黑棋走子 请输入落子坐标');
read(h,l);
end;
end;
if (h<>0)and(l<>0) then begin h1:=h; l1:=l; end;
while (pan[h,l]='○')or(pan[h,l]='●')or((h=0) and (l<>0))or((l=0) and (h<>0))or(h1<0)or(h1>15)or(l1<0)or(l1>15) do
begin
writeln('对不起 该处不能落子');
writeln('黑棋走子 请输入落子坐标');
read(h,l);
if (h<>0)and(l<>0) then begin h1:=h; l1:=l; end;
end;
if (h<>0) and(l<>0) then
begin
s1:=pan[h1,l1];
pan[h1,l1]:='○';
hui2:=true;
str(h1,p1);str(l1,p2);
ju1[z1]:='黑棋在'+p1+','+p2+'落子 ';
out;
end;
while (h=0) and (l=0) do
begin
pan[h1,l1]:=s1;
pan[h2,l2]:=s2;
out;
writeln('黑棋悔棋');
writeln('黑棋走子 请输入落子坐标');
hui2:=false;
dec(n1);
dec(z1);
dec(z2);
ju2[z2]:='';
ju1[z1]:='';
writeln('还可悔棋',n1,'次');
read(h1,l1);
h:=h1;
l:=l1;
while (pan[h1,l1]='○') or (pan[h1,l1]='●') or (h1<1) or (h1>15) or(l1<1) or (l1>15) do
begin
writeln('对不起 该处不能落子');
writeln('黑棋走子 请输入落子坐标');
read(h1,l1);
end;
s1:=pan[h1,l1];
pan[h1,l1]:='○';
hui2:=false;
str(h1,p1);str(l1,p2);
ju1[z1]:='黑棋在'+p1+','+p2+'落子 ';
out;
end;
if trytry1(h1,l1)=true then begin writeln('黑棋胜'); readln; juout; break; end;
inc(z2);
writeln('白棋走子 请输入落子坐标');
read(h,l);
while (h=0) and(l=0) and(hui2=false) do
begin
writeln('对不起,双方不能连续悔棋');
read(h2,l2); h:=h2;l:=l2;
while (pan[h2,l2]='○') or (pan[h2,l2]='●') or (h2<1) or (h2>15) or(l2<1) or (l2>15) do
begin
writeln('对不起 该处不能落子');
writeln('白棋走子 请输入落子坐标');
read(h2,l2);
h:=h2;l:=l2;
end;
end;
while (h=0) and(l=0) and(n2=0) do
begin
writeln('对不起,您的悔棋机会已用完');
writeln('白棋走子 请输入落子坐标');
readln(h,l);
while (pan[h,l]='○')or(pan[h,l]='●')or((h=0) and (l<>0))or((l=0) and (h<>0))or(h1<0)or(h1>15)or(l1<0)or(l1>15) do
begin
writeln('对不起 该处不能落子');
writeln('白棋走子 请输入落子坐标');
read(h,l);
end;
end;
if (h<>0)and(l<>0) then begin h2:=h; l2:=l; end;
while (pan[h,l]='○')or(pan[h,l]='●')or((h=0) and (l<>0))or((l=0)and (h<>0))or(h2<0)or(h2>15)or(l2<0)or(l2>15) do
begin
writeln('对不起 该处不能落子');
writeln('白棋走子 请输入落子坐标');
read(h,l);
if (h<>0)and(l<>0) then begin h2:=h; l2:=l; end;
end;
if (h<>0) and(l<>0) then
begin
s2:=pan[h2,l2];
pan[h2,l2]:='●';
hui1:=true;
str(h2,p1);str(l2,p2);
ju2[z2]:='白棋在'+p1+','+p2+'落子 ';
out;
end;
while (h=0) and (l=0) do
begin
pan[h1,l1]:=s1;
pan[h2,l2]:=s2;
out;
writeln('白棋悔棋');
writeln('白棋走子 请输入落子坐标');
hui1:=false;
dec(n2);
dec(n1);
ju1[z1]:='';
ju2[z2]:='';
writeln('还可悔棋',n2,'次');
read(h2,l2);
h:=h2;
l:=l2;
while (pan[h2,l2]='○') or (pan[h2,l2]='●') or (h2<1) or (h2>15) or(l2<1) or (l2>15) do
begin
writeln('对不起 该处不能落子');
writeln('白棋走子 请输入落子坐标');
read(h2,l2);
end;
s2:=pan[h2,l2];
str(h2,p1);str(l2,p2);
ju2[z2]:='白棋在'+p1+','+p2+'落子 ';
pan[h2,l2]:='●';
out;
end;
if trytry2(h2,l2)=true then begin writeln('白棋胜'); readln; juout; break; end;
until 1=2;
end;
begin
writeln('欢迎使用Free Pascal游戏程序');
readln;
writeln('作者:王子成 ');
readln;
writeln('翻版必究');
readln;
writeln;
writeln('游戏——五子棋');
readln;
n1:=0;
n2:=0;
while choose<>1 do
begin
writeln('1 开始游戏');
writeln('2 游戏说明');
writeln('3 设置');
writeln('4 退出');
readln(choose);
case choose of
1:;
2:begin
writeln('本游戏规则与传统五子棋规则相同,落子时需输入落子的行列;悔棋需在己方回合内输入“0 0”即可,双方不可连续悔棋');
readln;
end;
3:begin options; readln; end;
4:exit;
end;
end;
z1:=0;
z2:=0;
hui1:=false;
hui2:=false;
for i:=2 to 14 do
for j:=2 to 14 do
pan[i,j]:='╋';
for i:=1 to 15 do
begin
pan[1,i]:='┳';
pan[i,1]:='┣';
pan[15,i]:='┻';
pan[i,15]:='┫';
end;
pan[1,1]:='┏';
pan[1,15]:='┓';
pan[15,1]:='┗';
pan[15,15]:='┛';
out;
readln;
writeln('////游戏开始\\\\');
game;
readln;
readln;
end
以上就是关于如何使用free pascal全部的内容,包括:如何使用free pascal、关于 free Pascal 程序的解读、请帮我做一下下面几个freePascal程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)