主题:难题
SANQIUYE
[专家分:30] 发布于 2007-03-24 17:03:00
1。按照由大到小顺序排列10个数字。
2。若N=1,打印 1
N=4,打印 1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7
N=6,打印
1 2 3 4 5 6
20 21 22 23 24 7
19 32 33 34 25 8
18 31 36 35 26 9
17 30 29 28 27 10
16 15 14 13 12 11
要求输入任意N,输出规定图形。
求解!!!!!!!!
回复列表 (共3个回复)
沙发
游侠UFO [专家分:1200] 发布于 2007-03-24 19:45:00
这道题论坛上以前出现过,用循环解决.自己好好找找规律,顺便去查查以前的帖子!
板凳
bigchen [专家分:1940] 发布于 2007-03-24 21:05:00
第一题:
var
a:packed array[1..10] of integer;
i,j,t:integer;
begin
for i:=1 to 10 do read(a[i]);
for i:=1 to 9 do
for j:=i+1 to 10 do
if a[i]<a[j] then
begin
t:=a[i];a[i]:=a[j];a[j]:=t;
end;
for i:=1 to 10 do write(a[i]);
end.
3 楼
dannyloi [专家分:0] 发布于 2007-06-02 19:36:00
[b]this is my SOURCE,SOME people can just use some integer to finish it
you can change some source,it will be your answer [/b]
Magic Square
Background
Given an number N, draw a square, with length N using a sequence of number. ie. If N = 3, you should draw a square as follow.
1 2 3
8 4
7 6 5
Input
Input contains an integer N, where 1 <= N <= 19.
Output
Output a square with base N using numbers.
Sample input
4
Sample output
1 2 3 4
12 5
11 6
10 9 8 7
(1)-----------------------------------------------
var a,x,y,z,q,count:integer;
name:array[1..19,1..19] of integer;
begin
readln(x);
if ((x<=19) and (x>=1)) then begin
for y:=1 to x do
for z:= 1 to x do
name[y,z]:=0;
for y:=1 to x do
name[1,y]:=y;
count:=1;
for a:=2 to x do
begin
name[a,x]:=x+count;
count:=count +1;
end;
count:=x+x;
for y:=(x-1) downto 1 do
begin
name[x,y]:=count;
count:=count +1;
end;
count:=x+x+x-1;
for q:= x-1 downto 2 do
begin
name[q,1]:=count;
count:=count+1;
end;
for y:=1 to x do
for z:= 1 to x do
begin
if z=x then
if name[y,z]=0 then
writeln('':4)
else
writeln(name[y,z]:4)
else
if name[y,z]=0 then
write('':4)
else
write(name[y,z]:4);
end;
end;
end.
(2)THE OTHERS' SOURCE----------------------------------------------------------------
var n,i,j,k : integer;
begin
readln (n);
if n = 1 then
writeln('1':4)
else
begin
for j := 1 to n do
write (j:4);
writeln;
for j := 1 to n-2 do
begin
write ((n*n-(n-2)*(n-2) - j+1):4 );
for i := 1 to n-2 do
write (' ':4);
write ((n +j):4 );
writeln;
end;
for k := n downto 1 do
write ((n*n-(n-2)*(n-2)-(n-2)+(k-n)):4);
end;
end.
我来回复