Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Maths assessment.
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
daniel.parker
Maths assessment.
Commits
0a4d3a17
Commit
0a4d3a17
authored
Dec 13, 2018
by
daniel.parker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
final.
parent
4b4a9ef2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
17 deletions
+34
-17
Program.java
src/Program.java
+34
-17
No files found.
src/Program.java
View file @
0a4d3a17
...
...
@@ -64,18 +64,8 @@ public class Program {
public
static
void
main
(
String
[]
args
)
{
// TODO Auto-generated method stub
ConvertBinaryToInt
(
binaryInput
);
String
[]
input
=
{
"010"
,
"110"
,
"111"
,
"1010101"
};
String
[]
input2
=
{
"50"
,
"110"
,
"FA"
,
"B0"
,
"F"
};
int
[]
set
=
{
3
,
6
,
7
,
9
,
8
,
7
,
7
,
6
,
5
,
15
};
System
.
out
.
println
(
Median
(
set
));
System
.
out
.
println
(
ConvertSingb3ToInt
(
"12"
));
System
.
out
.
println
(
ConvertSingb20ToInt
(
"50"
));
System
.
out
.
println
(
ConvertSingleHexToInt
(
"50"
));
System
.
out
.
println
(
ConvertSingleBinaryToInt
(
"101"
));
System
.
out
.
println
(
Arrays
.
toString
(
ConvertBinaryToInt
(
input
)));
}
...
...
@@ -178,15 +168,31 @@ System.out.println(Median(set));
public
static
int
[]
Union
(
int
[]
intArrayA
,
int
[]
intArrayB
)
{
ArrayList
<
Integer
>
unionList
=
new
ArrayList
<
Integer
>();
for
(
int
i
=
0
;
i
<
intArrayA
.
length
;
i
++)
{
unionList
.
add
(
intArrayA
[
i
]);
}
for
(
int
i
=
0
;
i
<
intArrayB
.
length
;
i
++)
{
unionList
.
add
(
intArrayB
[
i
]);
}
unionList
.
sort
(
null
);
for
(
int
i
=
0
;
i
<
unionList
.
size
();
i
++)
{
for
(
int
j
=
0
;
j
<
unionList
.
size
();
j
++)
{
if
(
i
==
j
)
continue
;
if
(
unionList
.
get
(
j
).
equals
(
unionList
.
get
(
i
)))
unionList
.
remove
(
j
);
}
}
int
[]
resultsArray
=
new
int
[
unionList
.
size
()];
for
(
int
i
=
0
;
i
<
unionList
.
size
();
i
++)
{
resultsArray
[
i
]
=
unionList
.
get
(
i
);
System
.
out
.
println
(
resultsArray
);
}
return
resultsArray
;
...
...
@@ -213,18 +219,29 @@ System.out.println(Median(set));
public
static
int
[]
Difference
(
int
[]
intArrayA
,
int
[]
intArrayB
)
{
int
counter
=
0
;
ArrayList
<
Integer
>
differenceList
=
new
ArrayList
<
Integer
>();
for
(
int
i
=
0
;
i
<
intArrayA
.
length
;
i
++)
{
counter
=
0
;
for
(
int
j
=
0
;
j
<
intArrayB
.
length
;
j
++)
{
if
(
intArrayA
[
i
]==
intArrayB
[
j
])
{
counter
++;
}
}
if
(
counter
==
0
)
{
differenceList
.
add
(
intArrayA
[
i
]);
}
}
int
[]
resultsArray
=
new
int
[
differenceList
.
size
()];
for
(
int
i
=
0
;
i
<
differenceList
.
size
();
i
++)
{
resultsArray
[
i
]
=
differenceList
.
get
(
i
);
}
System
.
out
.
println
(
resultsArray
);
return
resultsArray
;
}
...
...
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