close

Вход

Забыли?

вход по аккаунту

?

Kursovaya(103)

код для вставкиСкачать
???????????? ??????????? ? ????? ?????????? ?????????
??????????? ??????????????? ????????? ??????????????? ???????????
??????? ????????????????? ???????????
"???????? ??????????????? ???????????"
??????? ?????????? ?????????? ? ???????????
????????
?? ???????? ?????? ?? ?????
"????????? ? ??????????????? ?????"
???????? ??. __________ _________________________________________
(??????? ??? ????????) ?? ????
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
??????? ?????????????? ????????????? ?????
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
??????? ?????????????? ??????????? ??????????
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
?????? ? ???????????
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
????????????? ?????? _________________________
????????? _________ ________________ _____________________________
(???????) (?????????) (??????? ????????)
????????? ???. ???????? ????
__________________ ?.?. ??????
"___" ____________ 20 __ ?.
???????
?? ???????? ?????? ?? ?????
"????????? ? ??????????????? ?????"
???????? ??. __________ _________________________________________
(??????? ??? ????????) ???? ?????? _______________________________________________________
__________________________________________________________________
__________________________________________________________________
??????? ??????____________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
??????? ??????? ______________ ____________________________
(???????) (????)
?????? ?????????? ?????? __________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
????????? ???????????? _____________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
? ??????. ??????????? ?????? ______________ _________________ (???????) (????)
???????????? ??????????? ? ????? ?????????? ?????????
??????????? ??????????????? ????????? ??????????????? ???????????
??????? ????????????????? ???????????
"???????? ??????????????? ???????????"
??????? ?????????? ?????????? ? ???????????
????????? ???. ???????? ????
__________________ ?.?. ??????
"___" ____________ 20 __ ?.
????????????? ???????
?? ???????? ?????? ?? ?????
"????????? ? ??????????????? ?????"
?? ????
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
????? ?????? _______________ ??????? ??. ________ ____________________
(???? ???????) (??????? ????????)
???????????? ?????? ______________ ___________ ___________________
(???? ???????) (?????????) (??????? ????????)
?????? ???????? _____________ ? ??????? ____________________________
(????)
????? ???????? ______________ ______________ ____________________
(???? ???????) (?????????) (??????? ????????)
______________ ______________ ____________________
(???? ???????) (?????????) (??????? ????????)
______________ ______________ ____________________
(???? ???????) (?????????) (??????? ????????)
???? 20___
????????
???????????? ??????:
?????? ? ?????? ?????? - ?????? ????????? ?????? ?? ??????????? ????? ?? ????????? ?????. ???????? ????????????: "?????? ????????? ????? ?????????? ?? ????? ?????? ?????? ???, ????? ??? ?? ???????? ???? ?????, ?.?. ??????? ??? ?? ?????? ?? ????? ?????????, ??????????? ? ????????? ? ??????? ????? ?????????" ????????, ?????? ?????? ?????? ?????? (??? ? ?????) ?? ??????? ????? ?????????? ??????????. ????? ?????-?????? ???????????? ?????? ??????, ?? ?????????? ???? ?????, ????? (?? ??????? ???????????? ?????? ??????? ???????????). ??????????? ??????? ?????????? ????? ????? ??????????? ? ??????? ??, ? ???, ??????????, ? ??????? ??????.
? ????? "??????????????" ???? ?????? ????? ???? ?????????????? ??????????? ?????????, ????????, ???: "????????? ??????? ???????? 8�8 ?????? ? ????????? ????? ???????, ????? ????? ???? ????????? ??????? ???? ????? 8, ??? ???? ????? ????????? ?? ? ????? ???????, ?????? ??? ???????????? ???? ??????? ?? ????????? ???????".
??????? ??????:
?????????, ??? ?????? ?????? ???????? ??????????? ??? ?????? ? ?? ??????? ?????? ?. ??????. ?? ????? ????, ??? ???? ??????? ?????????? ? 1848 ?. ???????? ??????????? ?. ????????. ?????? ?. ???? ????? 60 ??????? ? ??????????? ?? ? ?????? "Illustrierte Zeitung" ?? 1 ???? 1850 ?. ???? ????? ????? ????? ??????????????? ??????? ? ????? 72 ???????, ??????? ?? ??????? ? ?????? ? ?????? ????? ????????? ???????? ?? 2 ???????? 1850 ?. ?????? ?? ????? ???????, ????????? ?? 92 ???????, ??????? ??? ??? ?? ?. ????. ?? ?????? ?? ? ?????????? ?????? ?? 21 ???????? 1850 ?. ??? ?????????? ??????????? ????????? ???????? ?????????????? ?????????????? ??????????? ?. ???????.
??????? ?????????????? ????, ??? 92 ??????? ??????????? ??? ???????????, ???? ???????? ???? ? 1874 ?. ?????????? ??????????? ?. ???????? (??? ?????? ?????? ?????????????). ??????? ??????, ???????, ??? ???????????? ??????? (?? ??????????? ??? ?????????? ? ????????? ?????) ??????? ?????? ??????????.
???? ???????:
???????? ????, ???????????? ????? ???????? ??????, ????? ??????????????? ? ?????????? ?????????:
1) ????????? ????, ????? ??????? ??????.
2) ???????????? ????????, ??? ??????? ??????????.
3) ?????????? ?????????? ???????.
4) ????????? ??? ????????? ???????.
5) ???? ?? ??????? ????? ?? ???????????????? ?????????? ????????: ??????? ???????????? ?????????, ????????? ??? ????????? ??????? ??????.
?????? ?????????? ?????? ??????? ?????????? ???????? ??????????? N ?????? ?? ????? N�N ?????? (??? ???? ??? 1<N<4 ?????? ?? ????? ???????). ? ?????? ???? ???????? ?????????? ???????????? "?????????" ?????? ??? ????? 8*8. ? ????? ???????????? ????????? ????????? ?? ????? ???????? N*N.
1. ????????? ??????? ?????? ??? ????? 8*8.
1.1???????????? ??????:
?????????? ??????: ??? ?? ????????? ????? ??????????? ?????? ??????
????? ???????, ????? ??????? ??? ?? ??? ?? ???????? ???? ?????.
???????: ?????????? ????????? ?????, ?????? ??????? ???????? ? ???????
??????? ????????? ????????? ???????:
1111 1 2 3 4 5 6 7 81??? 12222 23333 34444 45555 56666 67777 78888 8 ????? ????????, ??? ??? ?????, ??????? ????????? ? ??????? ? ???????????? (x1, y1) ? (x2, y2), ????? ???? ???? ????? ???? ??????????? ???? ?? ???? ?? ????????? ????????:
1) x1 = x2, ?? ???? ????? ????????? ?? ????? ?????????;
2) y1 = y2, ?? ???? ????? ????????? ?? ????? ???????????;
3) x1+y1 = x2+y2, ?? ???? ????? ????????? ?? ????? ?????????, ??????
????? ????? ????? ???????. ??? ????????? ????? ?????? ??? ????????-
??? ????????? ?????? ????????? ?????;
4) x1-y1 = x2-y2, ?? ???? ????? ????????? ?? ????? ?????????, ?????? ?????? ???? ????? ???????. ??? ????????? ????? ????? ?????? ??? ??????????? ????????? ?????? ????????? ?????.
???????? ????????????? ??????? : ????????, ??? ??? ?????? ?????? ????????? ?? ?????? ?????????? ????????? ?????, ????? ???????? ??? ?? ???, ??????? ???? ???? ?????. ??????? ??? ????? ????????? ??? ??????? ????? ??? ????????? ???????????, ??? ?? ????? ?????? ? ?????????, ????? ??? ????? ?? ???? ??? ????. ??????? ?????? q, ?????? ???????? ????????????? ?????? ?????, ? ???????? q[i] ????????? ?? ????? ?? ????? ??????????? ????????? i-? ?????.
????????? ??????? ???????????? ?????????? ????????, ??????? ?????? ?????????? q1, . . . , q8, ??????? ????? ????????? ?? 1 ?? 8 ? ????????????? ???????????????? ????? ?? ????????? ???????????. ????????, ???? qi=4, ??? ??????, ??? i-?? ????? ?????????? ????????? ?? 4-? ???????????. ??????? ??????? boy(c), ??????? ? ???????? ????????? ????? ????????? ????? ????? ? ?????????, ?? ???? ?? ????? ? ??????? "c" ????? ? 1-?? ?? "c" - 1-??. ??? ??????? ?????????? ???????? "??????" ? ?????? ???? "c"-?? ????? ???? ???? ?? ???? ????? ? "????" ? ????????? ??????. ????-????? ?????????: ?????????? ????????? ?? ????? Pascal ????????? ? ??????????.
? ?????? ????????? ?????? ??? ????????? ??????? ?????? ? ????????? ?? ?????: 92. ????????? ????????, ??? ??? 92 ???????????? ??????????? ?? 12 ?????: ??? ?????? ????????? (????????) ????? ?? 90, 180 ? 270�, ? ????? ??? ?? ?????????? ????????? ???????????? ?????, ??????????? ????? ???????: ????????, ?? ???????????, ?????????? ?? ???. ?, ??? ???????? ????? ?? 90� ?? ??????? ??????? ?? ???????? ??????????? ?? ???. ?. ? ??? ????????? ????? ???????????? ?????, ??????????? ??????????? ? ???????? ??????, - ?? ???. ?. ??? ?????? ?????? ????????? ? ????????? ????? ????? ???????? ??? ???? ???????. ????? ??????????? ?????? ?????? ?????? ?????????? ????????, ????, ??-??????, ??? ??????????? ?? ????????? ???? ? ????? ??? ????????? ? ?????????? ?????, ?, ??-??????, ????? ?????? ??????????? ?????????? ?? ?????-?????? ???????? ??? ?????? ?????? ?????????????? ?????. ????????, ??? ?????? ???????? ????? ??????? ?????? ???????? ????? 12 ???????????. ??? ???? ?? ????? ???????:
1) ??. ???. ?;
2) ??. ???. ?;
3) a4, b1, c5, d8, e6, f3, g7, h2;
4) a4, b2, c5, d8, e6, f1, g3, h7;
5) a4, b2, c7, d3, e6, f8, g1, h5;
6) a4, b2, c7, d3, e6, f8, g5, h1;
7) a3, b5, c2, d8, e6, f4, g7, h1;
8) a4, b1, c5, d8, e2, f7, g3, h6;
9) a4, b7, c3, d8, e2, f5, g1, h6;
10) a6, b4, c2, d8, e5, f7, g1, h3;
11) a4, b8, c1, d5, e7, f2, g6, h3;
12) a4, b2, c7, d5, e1, f8, g6, h3.
????????? 80 ??????????? ?????????? ?? ???? ?????????? ??? ?????? ????????? ? ????????? ?????. ???????? ??????????? ?? ???. ? ???????? ??????????????. ?????? ??????????? ???????? ??????????? - ????????. ????, ????? ?? ????? ????? 11�8+1�4=92 ??????????? ?????? ??????, ?? ?????????? ???? ?????.
1.2. ????????? ???-?????? ??? ???????? ?????? ? ?????????:
????????? ???-?????? ??????? ?? ?????????? ???????????? ?????, ???? ?????? ??? ?? ?????????? ?????? ???????? ??????. ??? ?????? ???????? ??? ?????????, ??? ???? ??????????? ????, ??? ??? ?????? ?????????? ?????. ???????? ???-?????? ????????? ????????? ???????, ? ????? ?????????, ???????? ?? ??? ??????? ? ??????. ?????????, ???????????? ???????? ???-??????, ???????? ??? ??? ?? ?????, ???? ?? ?? ????????? ??????????. ???? ?????????? ????? success(aj) ? failure(a;) ?????, ??????????? ??? ????, ????? ???????? ?????????????? ????????????? ??? ????????????? ????? ?? ??????? ??????, ? ????? ?(?) ??????????? ????????? ?????????? ?????? ?????????, ?? ?? ???????? ? ?????????:
time(x) = ?(?) * success(a;) + (1 - ? ( ? ) ) * (failure(:r) + time(a;)).
??? ????????? ????????, ??? ? ?????? ?????? ??????????? ????? ????????? ? ???????? ????????? ????????? ??????????, ? ? ?????? ??????? ??????????? ????? ????? ????? ??????? ?? ?????????? ?????????? ?????????? ? ??? ?? ???? ????? ???????. ????? ??? ????????? ???????????? times(a;), ?? ????????:
time(a;) = ?(?) * success(a;) + (1 - ?(?}} * failure(a;) + (1 - p(a;))time(a;).
time(a;) - (1 - p(a;))time(a;) = p(x) * success(z) + (1 - p ( x ) ) * failure(a;).
time(a;) - time(x) + ?(?) * time(a;) = ?(?) * success(x) +
+ (1 -?(?)} *failure(x).
?(?) * time(ar) - ?(?) * success(x) + (1 - ? ( ? ) ) * failure(o).
time(x) = success(a;) + ((1 -p(x))/p(x)} * failure(a;).
??? ??????? ????????, ??? ????? ?????????? ??????? ?? ??????? ????????? ????????? ??????????, ???????????? ?????????? ? ??????????? ??????? ?? ???? ???????. ?????????, ??? ??? ???????? ??????????? ?(?) ????????? ?????????? ????? ?????????? ??? ????? ????? ???? ?????????, ???? ???????? ????????? ???????????? ?????????? ??????????. ??????? ????????????? ????? ????????, ???? ??????? ???????? ??????????? ?????????.
??? ????? ?????? ???????? ?? ????????? ????????? ? ?????? ? ??????????? ?????? ?????? ?? ????????? ????? ???, ????? ??? ?? ????
???? ?????:
?? ??????? ?????????? ???? ?? ??????? ???? ??????. ??????????? ???????? ?? ??????? ???????? ????? ? ?????? ?????? ?????? ?????????, ? ????? ???????? ???? ??? ????, ????? ????????? ????? ?? ?????? ???????????. ???? ? ?????-?? ?????? ????????? ?? ??????? ????? ????????? ??? ?????????? ????? ?? ????????? ???????????, ?? ???????? ???????????? ?? ?????????? ??? ? ??????? ?????? ?????????? ????? ?? ?????????? ??????.
??????? ????????????? ???????????? ?????????????????? ???????????? ?????????. ?? ????? ?????????? ????????? ?????? ?? ????? ????????? ??????? ?? ????????? ????????? ??????????? ?????. ??????? ????????? ???-?????? ?? ???????????? ???????????? ????????? ??????? ? ???, ??? ??? ????????????? ?????????? ?????????? ????? ???????? ???????? ??????? ? ???????? ? ???????. ??????????? ?? ???????? ???????? ???????? ?????????????? ??????????. ??? ??? ???????? ???????? ???-?????? ??? ??????????? ?????? ??????:
Queens(result)
result ???????? ?????? ?????????? ??? ??????
? ??????????????? ????????????
?????????? 1 ? ?????? ?????? ? 0 ? ?????? ???????
row=l
repeat
// ????? ??? ??????????? ? ???????????? l..row-l
spotsPossible=0
for i=l to 8 do
if ?????? (row.i) ????????? then
spotsPossible=spotsPossible+l
if uniform(l,spotsPossible)=l then
try=i
end if
end if
end for
if spotsPossible>0 then
result[row]=try
row=row+l
end if
return (spotsPossible>0)
?????????, ??? ???????? ???? ????????. ? ????? "repeat" ?? ???????? ?? ???? ?????? ???????????? ?????. ??? ?????? ?? ???????????? ?? ??????????????? ????????????? ??? ?? ???????? ? ???? ?????? ?? ?????????, ?? ?????????? "spotsPossible" ????????????? ?? ???????. ????????? ???????? "if" ???????? ????????? ???????, ?? ?????????, ??? ??????????, ???? ???????? ?????? ???????????, ?? ??????? ?? ????????? ?? ???? ??????. ?? ?????? ????????? ??????? "uniform" ?????????? ????????? ????? ????? 1 ? 1, ?.?. 1, ??????? ?????????? "try" ????? ????????? ?? ?????? ?????????. ?? ?????? ????????? "uniform" ?????????? ????? ????? 1 ? 2, ??????? ? 50%-??? ???????????? ????? ???????? ? ? 50%-??? ???????????? ???????, ??????? ??????????? ????, ??? ????? ????????? ?????????? "try" ?????? ??????, ????? 50%. ? ??????? ????????? "uniform" ?????????? ????? ????? 1 ? 3; ??? ????? ? ???????????? 33% ????? 1, ? ????? ? ???????????? 33% ???????? "try" ?????? ????? 3. ???????????? ?? ?????????, ??? ??? ?????? ?? ????????? ?????????? ??????????? ???? ???????????? ?? ?????? ??????? ????? 1/"spotsPossible". ????? ??? ??????????? ??? ????????? ????????????. ????? ???????? ???????????? ?? ??? ??? ???? ???? ???????? "spotsPossible" ?? ?????? ???????, ????? ?????????? ????????????? ??????, ???? ?????????? "rows" ?? ?????? ???????? 9, ????????? ??? ????? ????? ???????????. ? ?????? ?????? ???????? ????????? ???? ?????? ? ???????? ? ????????? ??????. ?? ?????? ???????? ??????????? ?????? ?????? ??????, ? ???????? ???????? ?? ??????? ??????.
?????? ?????????????? ?????? ????????? ??????????, ??? ??????????? ?????? ????? 0.1293, ? ??????? ????? ??????????, ??????????? ??? ??? ??????????, ????? 6.971. ??????????? ???? ????????? ??????????, ??? ???????? ???????? ??? ???? 55 ????????. ???????????? ?? ????????? ???????????, ?? ??????? ????, ????? ?????? ????????.
2. ????????? ??????? ?????? ????? N*N.
2.1. ???????????? ????????:
?? ????? 1?1 ???? ????? ???????? ?? ????-???????????? ????, ? ??????? ??????????. ?? ????? 2?2 ???? ?????, ??? ?? ?? ?????, ???????? ?? ??? ?????? ????, ? ??????? ????? ????????? ??????. ?? ????? 3?3 ????????? ?????? ??? ?????? ?????. ????, ??? ????? 2?2 ? 3?3 ?????? ?? ????? ???????. ??? ??? ?????? ???????????? ????? ??????????. ??? ???? N > 3 ?? ????? NxN ????? ?????????? n ?? ?????????? ???? ????? ??????.
?? ????? 4x4 ?????????? ???? ???????? ???????????, ?????? ?????? ??????????????: a2, b4, c1, d3, ?.?. ????? ??????? ??? ???????. ?? ????? 5x5 ???????? ??????????? ???: 1) a2, b4, c1, d3, e5; 2) a2, b5, c3, d1, e4. ????? ????? ??????????? ????? ??????, ?????? ?? ??? ????? ??????? ???? ?????, ??? ????????? ??????? ???? ?? ????? 25 ?????? ????????? ??? ???? ????? 5?5.
???????, ??? ? ????? ?????? N ??????????? (??????? ??????) ????? ????????? ??? ????????? ??? ????? N?N ?????? ??? ??? n, ??????? ?? ?????? ???? ? ????. ?? ?????, ? ?????????, ???????, ??? ??? ??????? ????? ????????? ?????? ???????????, ??????????? ??? 64 ???? ?????, ??????????.
???????????? ???????? ?????? N ?????? ???????? ?????? ??????? ? ??????????. ?????? ??????? ??????????? ? ????????? ?? ????????????? ???? ????????? ??????????. ????????, ?? ????? ?????????? N^2 ???????, ????? ???????, ?? ????? N^2 ????????? ??????? ??? ??????? ?????, N^2-1 ??? ??????? ? ?.?. ????? ????? ????????? ???????????? ???? ?????? ?????????? (N^2, N) = (N^2)!/((N^2-N)! * n!). ???? ????????? ??? ??? ???????, ????? ????? ??? ?????????? ???????. ??? n=10 ????? ???? ??????? ????? ~1.73*10^13.
????????? ? ????????????? ???????????? ?? ????? ??????????? ????? ?????? ?????? ???? ?????, ?? ?? ????? ???????????? ???????????? ?????? ????? ?? ?????? ???????????, ??????? - ?? ?????? ? ?.?. ??? ???? ??? N ????????? ????????? ??? ??????? ????? ? N^N ????????? ????????????. ??? N=10 ??? ????? 10^10. ???????, ??? ?? ?????? ????????? ????? ????? ???? ?????? ???? ?????: i-? ????? ????? ?????? n-i+1 ????????? ?????????, ????????? ?????????? i-1 ?????? ??? ?????? i-1 ??????????. ?????? ????? ?????????? ???????????? ??????????? ?? N! ??? 3.6*10^6 ????????? ??? n=10.
? ????????? ?????? ????????? ?????????? ????????? ????????? - ?????????????? ????????? ?????? ?? ????? ?????????. ???? ??? ?????? ?????????????????, ?????? ?????? ???? ?????? ?????????? ???????????? ?????????. 2.2. ????????? ???-?????? ??? ???????? ?????? ? ?????????:
???? ?????? ????? ????? ?????? ?? N ??????, ?? ????? ??????? ????????? ???? ? ?????????????? ????????? ???? ?????????? ????? ?????? ????? ???????? ??? ??? N = 20, ??? ??? 20! = 2.433�10^18.
2.3. ????????????? ????????:
????????????? ???????? (?????????) - ???????? ??????? ??????, ?? ??????? ???????? ???????????, ??, ??? ?? ?????, ?????? ?????????? ??????? ?????? ? ??????????? ??????????? ???????? ???????. ????????????? ???????? - ??? ???????? ??????? ??????, ???????????? ???????? ??? ???? ????????? ??????? ?? ????????, ?? ??? ??????? ????????, ??? ?? ???? ?????????? ??????? ??????? ? ??????????? ???????. ? ???????????????? ????? ???? ???? ???????? (?? ???? ????????) ??, ??? ????????????? ???????? ????????? ???????. ??? ??? ????? ????? ?????????, ???? ??? ???? ?? ???? ???????? ????????? ?????? ? ?????????, ?????????? ?????? ? ?????? ?????????? ???????, ??? ?? ???? ????????, ?? ??? ?? ?????????? ?????????.
??? ??????? ???????????? ?????? ????????????? ???????? ????? ????????? ???:
1) ????????? N ?? 12 ? ????????? ??????? (N ????? ????? 8 ??? ?????? ? ?????? ??????).
2) ??????? ? ?????? ??? ?????? ????? ?? 2 ?? N ?? ???????.
3) ???? ??????? ????? 3 ??? 9, ????????? 2 ? ????? ??????.
4) ???????? ? ?????? ??? ???????? ????? ?? 1 ?? N ?? ???????, ??, ???? ??????? ????? 8, ??????????? ???? ???????? ????? (????????: 3, 1, 7, 5, 11, 9, ...).
5) ???? ??????? ????? 2 ? N = 3, ???????? ??????? 1 ? 3, ?????, ???? N = 5, ????????? 5 ? ????? ??????.
6) ???? ??????? ????? 3 ??? 9, ??????????? 1 ? 3 (?????? ? ???? ???????, ? ?? ? ??????? ??? ??????) ? ????? ??????.
7) ?????????? ????? ? ?????? ??????? ? ? ?????? ? ???????, ?????? ??????? ???????? ??????, ????? ????????? ?????????? ????? ?? ?????? ??????? ? ? ?????? ? ???????, ?????? ??????? ???????? ??????, ? ?.?..
???????:
8 ?????? (??????? 8): 2, 4, 6, 8, 1, 3, 5, 7.
14 ?????? (??????? 2): 2, 4, 6, 8, 10, 12, 14, 3, 1, 7, 9, 11, 13, 5.
15 ?????? (??????? 3): 4, 6, 8, 10, 12, 14, 2, 5, 7, 9, 11, 13, 15, 1, 3.
20 ?????? (??????? 8): 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 3, 1, 7, 5, 11, 9, 15, 13, 19, 17.
??????????
?????????? ?????? ????????? ????? ????????, ??? ?? ????????????? ???????? ??????? ?? ??????? "?????". ??? ????????? ??????? ?? ????????????? ??????????? ???????? ???-??????. ? ??? ?????????? ??????? ??????????? ???????????? ? ?????????????. ??, ?.?. ????????????? ???????? ?? ??? ???? ????????? N, ?? ????? ??????????? ?? ???????????? ???????? ????????????. ?????? ??????????
1) ?. ??????? ?????????????? ??????. - 2-? ???., ????. ? ???. ?: ???, 2000. - 444 ?.
2) ??. ???????? ?????? ??????????? ??????????. - 2-? ???., ?: ????????, 2004. - 368c.
3) ?. ???????? ???????????????? ?????? ? ?????? ?????????? ???. - 1-?? ???., C-??: ???-?????????, 2005. - 272c.
4) ?. ??????? ???????? ? ?????? ? ?????????? ?????????? - ?: ???????, 2006. - 576c.
5) ???? ?. ????????? ? ????????? ?????? - C-??.; ??????? ???????, 2005. - 352?.
6) ?. ???, ??. ???????, ??. ?????? ?????????? ? ?????? ?????????????? ?????????? - ?: ???, 1979. - 135c.
7) ?. ???? ????????? ???????????????? ?.2 - ?:1968. - 788c.
?????????? 1.
????? ?????????
program Queens ;
var q : array [1..8] of integer ;
I , q1 , q2 , q3 , q4 , q5 , q6 , q7 , q8 , n : integer ;
function boy ( c : integer ) : boolean ;
var j : integer ;
res: boolean ;
begin
res :=false ;
for j :=1 to c-1 do
res :=res or ( ( c=j ) or ( q [ c ]=q [ j ] ) or
( ( c+q [ c ] )=( j+q [ j ] ) ) or ( ( c-q [ c ] )=( j-q [ j ] ) ) ) ;
boy:=res ;
end;
begin
n:=1;
for i :=1 to 8 do q [ i ] :=1 ;
for q1 :=1 to 8 do
begin
q [ 1 ] := q1 ;
for q2 :=1 to 8 do
begin
q [ 2 ] := q2 ;
if ( not ( boy ( 2 ) ) ) then
for q3 :=1 to 8 do
begin
q [ 3 ] := q3 ;
if ( not ( boy ( 3 ) ) ) then
for q4 :=1 to 8 do
begin
q [ 4 ] := q4 ;
if ( not ( boy ( 4 ) ) ) then
for q5 :=1 to 8 do
begin
q [ 5 ] := q5 ;
if ( not ( boy ( 5 ) ) ) then
for q6 :=1 to 8 do
begin
q [ 6 ] := q6 ;
if ( not ( boy ( 6 ) ) ) then
for q7 :=1 to 8 do
begin
q [ 7 ] := q7 ;
if ( not ( boy ( 7 ) ) ) then
for q8 :=1 to 8 do
begin
q [ 8 ] := q8 ;
if ( not ( boy ( 8 ) ) ) then
begin
writeln ( 'Solution ' ,n ) ;
for i :=1 to 8 do writeln ( '(' , i , ',' , q [ i ] , ') ' , boy ( i ) ) ;
inc (n ) ;
end;
end;
end;
end;
end;
end;
end;
end;
end;
readln;
end.
1
Документ
Категория
Без категории
Просмотров
21
Размер файла
143 Кб
Теги
103, kursovaya
1/--страниц
Пожаловаться на содержимое документа