Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Никита Савельев
JavaProjects
Commits
a767d01f
Commit
a767d01f
authored
2 years ago
by
Никита Савельев
Browse files
Options
Download
Patches
Plain Diff
HashMap
parent
ed72bb19
main
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Map/src/main/java/ru/map/KeyPair.java
+14
-0
Map/src/main/java/ru/map/KeyPair.java
Map/src/main/java/ru/map/Main.java
+3
-1
Map/src/main/java/ru/map/Main.java
with
17 additions
and
1 deletion
+17
-1
Map/src/main/java/ru/map/KeyPair.java
+
14
−
0
View file @
a767d01f
...
...
@@ -8,4 +8,18 @@ public class KeyPair { // SparseMatrix
this
.
i
=
i
;
this
.
j
=
j
;
}
public
void
get
(
Integer
index
)
{
// проверка на то, есть ли нулевые значения
if
(
index
>=
this
.
i
||
index
>=
this
.
j
)
{
throw
new
IllegalArgumentException
(
"invalid index"
);
}
}
public
void
set
(
Integer
index
,
Integer
value
)
{
if
(
index
>=
this
.
i
||
index
>=
this
.
j
)
{
throw
new
IllegalArgumentException
(
"invalid index"
);
}
if
(
index
!=
0
)
System
.
out
.
println
(
value
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Map/src/main/java/ru/map/Main.java
+
3
−
1
View file @
a767d01f
...
...
@@ -69,10 +69,12 @@ public class Main {
boolean
value8
=
x
.
contains
(
"8"
);
if
(
value8
)
{
KeyPair
m
=
new
KeyPair
(
10
,
10
);
KeyPair
m
=
new
KeyPair
(
10
,
10
);
// номер строки и столбца
KeyPair
n
=
new
KeyPair
(
10
,
10
);
System
.
out
.
println
(
m
);
System
.
out
.
println
(
n
);
m
.
get
(
2
);
n
.
set
(
3
,
1
);
String
s
=
sc
.
nextLine
();
boolean
x1
=
s
.
contains
(
"1"
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets