,,,
1
2
3 -
4
5
. . . , . , , .. , , . , .
. , , n ( ). : , , . . , . , , , , , . . , .
, , , . , , , , . , , , 1. , , , .
1
, , .
, , , , , .
: , .
. , . , . , . k k! ( k).
, , n . , , n . . , , , .
1.
, , .
: -, .. .
: , , , . , - , . , , .
:
1) , ;
2) ( ), ;
3) , .
, : , . , .
- . . , , . , . *, ~ . , . .
. ( ), . , , ( ), . - , , . . . , , .
. . ( ) , , . , , .
1 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 |
1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 |
1 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
.
1. , .
2. = 1 , *;
3. = 0 , ~;
4. = * = ~, , 1.
, .
* | * | * | * | ~ | ~ | * | ~ | ~ | ~ |
~ | ~ | ~ | ~ | ~ | ~ | * | ~ | ~ | ~ |
~ | ~ | ~ | ~ | * | ~ | * | ~ | ~ | ~ |
* | ~ | ~ | ~ | * | ~ | ~ | ~ | ~ | ~ |
~ | ~ | ~ | ~ | ~ | ~ | ~ | ~ | ~ | ~ |
~ | ~ | ~ | ~ | 0 | ~ | ~ | ~ | ~ | ~ |
~ | ~ | * | ~ | ~ | ~ | ~ | ~ | 0 | * |
~ | ~ | ~ | ~ | ~ | ~ | ~ | ~ | ~ | * |
~ | ~ | ~ | ~ | * | * | ~ | ~ | ~ | ~ |
* | ~ | * | ~ | ~ | ~ | ~ | * | * | * |
, .
2.
,
n . k- , .
, n ,
,
, n n . , . , , k-
.
.
k . , , .., k . n 1 k 1 ( , ), k! (n k)!:)!. k
. (1)
. n . ( ) k. , , , , . k- .
, m- m , k-
.
k , , k .
,
, , , , .
. (2)
, k m . k . , , , . , , , , . . n , k
. (3)
,
,
.
.
100
) - ;
) ;
) ;
10, 6, 16.
) ;
) ;
) .
3.
2.
2 BLOW
4.
;
(setq input_stream (open d:\\field.txt:direction:input))
;
(setq field (read input_stream))
;
(close input_stream)
;
(setq user_ship 10)
;
(defun set_missing_comp (lst i j ip jp)
(setq k (if (>= (- i 1) 0) (- i 1) i))
(setq l (if (>= (- j 1) 0) (- j 1) j))
(loop
(do
()
((or (> k (+ i 1)) (>= k 10)))
(do
()
((or (> l (+ j 1)) (>= l 10)))
(if (eql (nth l (nth k lst)) 1)
(progn
(setq k 10)
(return t)
)
)
(setq l (+ l 1))
)
(setq k (+ k 1))
)
(return nil)
)
(setq k (if (>= (- i 1) 0) (- i 1) i))
(setq l (if (>= (- j 1) 0) (- j 1) j))
(loop
(do
()
((or (> k (+ i 1)) (>= k 10)))
(do
()
((or (> l (+ j 1)) (>= l 10)))
(if (not (eql (nth l (nth k lst)) '*)) (setf (nth l (nth k lst)) '~))
(setq l (+ l 1))
)
(setq k (+ k 1))
)
(return nil)
)
t
)
;
(defun set_missing (lst i j ip jp)
(if (>= (- i 1) 0)
(if (and (/= (- i 1) ip) (eql (nth j (nth (- i 1) lst)) 1))
(set_missing lst (- i 1) j i j)
)
)
(if (>= (- j 1) 0)
(if (and (/= (- j 1) jp) (eql (nth (- j 1) (nth i lst)) 1))
(set_missing lst i (- j 1) i j)
)
)
(if (< (+ i 1) 10)
(if (and (/= (+ i 1) ip) (eql (nth j (nth (+ i 1) lst)) 1))
(set_missing lst (+ i 1) j i j)
)
)
(if (< (+ j 1) 10)
(if (and (/= (+ j 1) jp) (eql (nth (+ j 1) (nth i lst)) 1))
(set_missing lst i (+ j 1) i j)
)
)
(if (eql (nth j (nth i lst)) 1) (setf (nth j (nth i lst)) '*))
)
; ,
(defun blow(lst)
;
(setq i (random 10))
(setq j (random 10))
(setq n (nth j (nth i lst)))
(cond
((eql n 1)
(progn
; = 1
;
(set_missing lst i j i j)
(set_missing_comp lst i j i j)
(setq user_ship ( user_ship 1))
(if (/= user_ship 0) (blow lst))
)
)
((eql n 0)
(progn
; 0
;
(setf (nth j (nth i lst)) '~)
(blow lst)
)
)
;
((or (equal n '*) (equal n '~)) (blow lst))
)
lst
)
; !!!
(blow field)
;
(setq output_stream (open d:\\destroy_field.txt:direction:output))
;
(print field output_stream)
;
(close output_stream)
5.
1.
3
4
2.
5
6
3.
7
8
, , . , , .
. .
1. , .. [] / .. , .. . .: , 2007. 708 .
2. , .. : . [] / .. , 3- .:-, 2006. C. 412.
3. , .. [ ] / .. , .. . .: , 1992. . 314.
4. [ ] : http://aka-alex.narod.ru/index.htm
5. , .. . [] / .. , .. . .: , 2006. C. 346.
6. , .. [] / .. , .. , .. . : , 2002. 160 .
7. , .. Lisp. [ ] / .. , .. . .: , 2003. . 79.
8. . [] / . , . . .: , 1990. 460 .
1 2 3 - 4 5
Copyright (c) 2024 Stud-Baza.ru , , , .