Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wu-e002
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jose Figueredo
wu-e002
Commits
ec5bbb7d
Commit
ec5bbb7d
authored
Sep 01, 2020
by
Jose Figueredo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
segunda tarea
parents
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
160 additions
and
0 deletions
+160
-0
VacasToros.java
+157
-0
readme.md
+3
-0
No files found.
VacasToros.java
0 → 100644
View file @
ec5bbb7d
import
java.util.*
;
public
class
VacasToros
{
private
String
numero
;
private
char
a
[];
private
int
vacas
;
private
int
toros
;
public
VacasToros
(
String
n
){
this
.
numero
=
n
;
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
a
[
i
]
=
n
.
charAt
(
i
);
}
verificar
(
a
);
}
public
boolean
verificar
(
char
a
[]){
int
bandera
=
0
;
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
for
(
int
j
=
0
;
j
<
4
;
j
++)
{
if
(
a
[
i
]==
a
[
j
]
&&
i
!=
j
)
{
bandera
=
1
;
j
=
4
;
i
=
10
;
}
}
}
if
(
bandera
==
1
)
return
false
;
return
true
;
}
public
boolean
verificar
(
String
c
){
char
d
[]=
new
char
[
4
];
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
d
[
i
]
=
c
.
charAt
(
i
);
}
int
bandera
=
0
;
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
for
(
int
j
=
0
;
j
<
4
;
j
++)
{
if
(
d
[
i
]==
d
[
j
]
&&
i
!=
j
)
{
bandera
=
1
;
j
=
4
;
i
=
10
;
}
}
}
if
(
bandera
==
1
)
return
false
;
return
true
;
}
public
void
comparar
(
String
n
){
char
b
[]=
new
char
[
4
];
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
b
[
i
]
=
n
.
charAt
(
i
);
}
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
if
(
a
[
i
]==
b
[
i
])
{
toros
++;
}
else
{
for
(
int
j
=
0
;
j
<
4
;
j
++)
{
if
(
a
[
i
]==
b
[
j
])
{
vacas
++;
}
}
}
}
System
.
out
.
println
(
"VACAS :"
+
vacas
+
" TOROS: "
+
toros
);
}
public
static
void
main
(
String
[]
args
)
{
VacasToros
juego
=
new
VacasToros
(
"1521"
);
Scanner
teclado
=
new
Scanner
(
System
.
in
);
String
a
=
teclado
.
nextLine
();
String
b
=
teclado
.
nextLine
();
while
(
juego
.
verificar
(
a
)
&&
juego
.
verificar
(
b
))
{
juego
.
comparar
(
b
);
// no pude terminar por tiempo
}
}
}
readme.md
0 → 100644
View file @
ec5bbb7d
compilar javac VacasToros.java
ejecutar java VacasToros
\ No newline at end of file
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