主题:TJu1001
排版题.输出排列成菱形的字母
Time Limit:1s Memory Limit:1000k
Total Submit:14651 Accepted:4031
下载样例程序(PE)
--------------------------------------------------------------------------------
Problem
输入N值,编程输出如下图形。
Input
一个整数N(1<=N<=7)。
Output
排列成菱形的大写字符,首字符为Z,以后依次为Y,X...
Sample Input
3
Sample Output
Z Y XW V U T S
以下是我的程序:
Program TJU1001;
VAR
pos1,pos2,i,m,n,lne:byte;
ch:array[1..24]of char;
BEGIN
readln(n);
for i:=1 to (4*n-4) do
BEGIN
ch[i]:='Z';
dec(i);
END;
writeln(ch[1]:11);
for lne:=2 to n do
BEGIN
pos1:=12-lne;
pos2:=2*lne-3;
write(ch[2*lne-2]:pos1);
write(ch[2*lne-1]:pos2);
END;
for lne:=(n+1) to (2*n-2) do
BEGIN
pos1:=lne-2;
pos2:=25-2*lne;
write(ch[2*lne-2]:pos1);
write(ch[2*lne-1]:pos2);
END;
writeln(ch[2*n-2]:11);
END.
可是我总是超时,规定1秒内完成,而我总是2秒才完成。这是什么原因?我该如何改进程序?
帮帮忙,多谢!
Time Limit:1s Memory Limit:1000k
Total Submit:14651 Accepted:4031
下载样例程序(PE)
--------------------------------------------------------------------------------
Problem
输入N值,编程输出如下图形。
Input
一个整数N(1<=N<=7)。
Output
排列成菱形的大写字符,首字符为Z,以后依次为Y,X...
Sample Input
3
Sample Output
Z Y XW V U T S
以下是我的程序:
Program TJU1001;
VAR
pos1,pos2,i,m,n,lne:byte;
ch:array[1..24]of char;
BEGIN
readln(n);
for i:=1 to (4*n-4) do
BEGIN
ch[i]:='Z';
dec(i);
END;
writeln(ch[1]:11);
for lne:=2 to n do
BEGIN
pos1:=12-lne;
pos2:=2*lne-3;
write(ch[2*lne-2]:pos1);
write(ch[2*lne-1]:pos2);
END;
for lne:=(n+1) to (2*n-2) do
BEGIN
pos1:=lne-2;
pos2:=25-2*lne;
write(ch[2*lne-2]:pos1);
write(ch[2*lne-1]:pos2);
END;
writeln(ch[2*n-2]:11);
END.
可是我总是超时,规定1秒内完成,而我总是2秒才完成。这是什么原因?我该如何改进程序?
帮帮忙,多谢!