turbo pascal编程 帮我看一下我编的哪错了

王朝知道·作者佚名  2009-04-09
窄屏简体版  字體: |||超大  
 
分類: 電腦/網絡 >> 程序設計 >> 其他編程語言
 
問題描述:

const maxn=10;var j,k,i,n:longint;a:array[1..maxn]of longint;procedure print;var i:longint;beginfor i:=1 to n dowrite(a[i]);end;function place:boolean;var i,j,n:longint;beginif place:=true then for i:=2 to n dofor j:=1 to i-1 doif (a[i]=a[j])then begin place:=false;break;end;end;procedure try(dep:longint);var i,n:longint;beginif place:=true thenbeginif dep>n then printelsefor i:=1 to n dobegina[dep]:=i;try(dep+1);end;end;end;beginread(n);try(1);end.

參考答案:

program aa; {add}

const maxn=10;

var j,k,i,n:integer;

a:array[1..maxn]of longint;

procedure print;

var i:integer;

begin

for i:=1 to n do

write(a[i],' ');

end;

function place( ):boolean; { add ()}

var i,j,n:longint;

p: boolean;

begin

for i:=2 to n do

for j:=1 to i-1 do

if (a[i]=a[j])then begin place:=false; exit; end;

place:=true;

end;

procedure try(dep:integer);

var i,n:integer;

begin

if place()=true then {rewrite}

begin

if dep>n then print

else

for i:=1 to n do

begin

a[dep]:=i;

try(dep+1);

end;

end;

end;

begin

read(n);

try(1);

end.

参考资料:你要告诉我你要做什么.程序还是写简单点的好。不要复杂化,这是你写的吗?按你的意思改这程序什么也不能做

小贴士:① 若网友所发内容与教科书相悖,请以教科书为准;② 若网友所发内容与科学常识、官方权威机构相悖,请以后者为准;③ 若网友所发内容不正确或者违背公序良俗,右下举报/纠错。
 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航