壹般是這樣的習慣:
像if , for ,repeat, while...有包含步驟的,就將其子步驟的每壹句都向後敲兩個空格,同壹級別的內容對齊,如果有begin
...end 就在多敲壹行(看樣例),這樣會使程序具有可讀性,步驟的包含關系很明確,另外begin end 可以對的很齊,就會減少錯誤。
隨便找了個程序,給妳個例子:
program contest;
var a,b:array[1..100,1..100]of boolean; {var下得定義內容對齊}
bo:array[1..100]of boolean;
l,r:array[1..100]of longint;
t,k,m,n,i,j,an:longint;
procedure soua(i:longint);
var t,k:longint;
begin
for t:=1 to n do
if (a[i,t])and(not(bo[t])) then {for包含的內容向後空兩格}
begin
bo[t]:=true;
inc(an);
soua(t); {begin end 中間的內容屬於同壹級別,對齊}
end; {begin end對的很齊吧}
end;
procedure soub(i:longint);
var t,k:longint;
begin
for t:=1 to n do
if (b[i,t])and(not(bo[t])) then
begin
bo[t]:=true;
inc(an);
soub(t);
end;
end;
begin
assign(input,'contest.in');
reset(input);
assign(output,'contest.out');
rewrite(output);
readln(n,m);
for t:=1 to m do
begin
readln(i,j);
a[i,j]:=true;
b[j,i]:=true;
end;
for t:=1 to n do
begin
fillchar(bo,sizeof(bo),false);
an:=0;
for k:=1 to n do
if (a[t,k])and (not(bo[k])) then
begin
bo[k]:=true;
inc(an);
soua(k);
end;
l[t]:=an;
an:=0;
for k:=1 to n do
if (b[t,k])and (not(bo[k])) then
begin
bo[k]:=true;
inc(an);
soub(k);
end;
r[t]:=an;
end;
an:=0;
for t:=1 to n do
if l[t]+r[t]=n-1 then inc(an);
writeln(an);
close(output);
end.
這個程序裏沒有repeat while 的對齊方法,其實道理和for壹樣,這樣對齊,空格就可以了。
居無定法,LZ如果找到自己順手的方法也是很好的,壹個人壹個習慣嘛...