Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
police and thief
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9731075
police and thief
Commits
ff9f1406
Commit
ff9f1406
authored
Apr 15, 2019
by
hosein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playground -> change | void added!
parent
8e79b040
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
+17
-5
PlayGround.java
src/PlayGround.java
+17
-5
No files found.
src/PlayGround.java
View file @
ff9f1406
...
...
@@ -2,11 +2,12 @@ import java.util.Random;
public
class
PlayGround
{
private
int
[][]
ground
;
int
n
,
m
;
int
n
,
m
,
policeNumbers
;
PlayGround
(
int
n
,
int
m
)
{
PlayGround
(
int
n
,
int
m
,
int
policeNumbers
)
{
this
.
n
=
n
;
this
.
m
=
m
;
this
.
policeNumbers
=
policeNumbers
;
ground
=
new
int
[
n
][
m
];
int
i
,
j
;
for
(
i
=
0
;
i
<
n
;
i
++)
...
...
@@ -29,11 +30,11 @@ public class PlayGround {
}
}
public
void
putRandom
(
int
policeNumber
)
{
public
void
putRandom
()
{
int
i
,
j
,
k
;
Random
rand
=
new
Random
();
if
(
n
*
m
>
policeNumber
)
for
(
k
=
0
;
k
<
policeNumber
;
k
++)
{
if
(
n
*
m
>
policeNumber
s
)
for
(
k
=
0
;
k
<
policeNumber
s
;
k
++)
{
i
=
rand
.
nextInt
();
j
=
rand
.
nextInt
();
if
(
ground
[
i
][
j
]
==
0
)
...
...
@@ -43,5 +44,16 @@ public class PlayGround {
else
System
.
out
.
println
(
"Error!! police numbers are higher than n*m"
);
}
public
void
change
(
int
[][]
newPolicesSituation
,
int
xThief
,
int
yThief
)
{
int
i
,
j
;
for
(
i
=
0
;
i
<
n
;
i
++)
for
(
j
=
0
;
j
<
m
;
j
++)
ground
[
i
][
j
]
=
0
;
for
(
i
=
0
;
i
<
policeNumbers
;
i
++)
ground
[
newPolicesSituation
[
i
][
0
]][
newPolicesSituation
[
i
][
1
]]
=
1
;
ground
[
xThief
][
yThief
]
=
-
1
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment